以下代码麻烦帮改正,最好加上注释,谢谢!
<?
$upload_file=$_FILES["imgfile"]["name"]; //获取文件名
$upload_tmp_file=$_FILES["imgfile"]["tmp_name"]; //获取临时文件名
$upload_filetype=$_FILES["imgfile"]["type"]; //获取文件类型
$upload_size=$_FILES["imgfile"]["size"]; //获取文件大小
$upload_status=$_FILES["imgfile"]["error"]; //获取文件出错情况if($upload_file!=""){$temp_arr = explode(".", $upload_file);
$file_ext = array_pop($temp_arr);
$file_ext = trim($file_ext);
$file_ext = strtolower($file_ext);//取得图片后缀 $upload_file = my.".".$file_ext;
$upload_path=$dir."/".$upload_file; //定义文件最终的存储路径和名称
if(is_uploaded_file($upload_tmp_file) )
{
if(move_uploaded_file($upload_tmp_file,$upload_path)){list($width_orig, $height_orig) = getimagesize($upload_path);
if ($width_orig>61||$height_orig>61) {
$image_p = imagecreatetruecolor(61, 61);
if($piece[1]=="jpg"||$piece[1]=="jpeg"){
$image = imagecreatefromjpeg($upload_path);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagejpeg($image_p,$upload_path);
}else if($piece[1]=="gif"){
$image = imagecreatefromgif($upload_path);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagegif($image_p,$upload_path);
}
}
}
<?
$upload_file=$_FILES["imgfile"]["name"]; //获取文件名
$upload_tmp_file=$_FILES["imgfile"]["tmp_name"]; //获取临时文件名
$upload_filetype=$_FILES["imgfile"]["type"]; //获取文件类型
$upload_size=$_FILES["imgfile"]["size"]; //获取文件大小
$upload_status=$_FILES["imgfile"]["error"]; //获取文件出错情况if($upload_file!=""){$temp_arr = explode(".", $upload_file);
$file_ext = array_pop($temp_arr);
$file_ext = trim($file_ext);
$file_ext = strtolower($file_ext);//取得图片后缀 $upload_file = my.".".$file_ext;
$upload_path=$dir."/".$upload_file; //定义文件最终的存储路径和名称
if(is_uploaded_file($upload_tmp_file) )
{
if(move_uploaded_file($upload_tmp_file,$upload_path)){list($width_orig, $height_orig) = getimagesize($upload_path);
if ($width_orig>61||$height_orig>61) {
$image_p = imagecreatetruecolor(61, 61);
if($piece[1]=="jpg"||$piece[1]=="jpeg"){
$image = imagecreatefromjpeg($upload_path);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagejpeg($image_p,$upload_path);
}else if($piece[1]=="gif"){
$image = imagecreatefromgif($upload_path);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagegif($image_p,$upload_path);
}
}
}
解决方案 »
- 关于实现校园易物的一些问题
- 所有用户共享一个(可修改,却不能改变)表的内容
- php链接mysql的一个问题。。
- 很久不上来了 散分散分
- 简单问题,帮忙写个正则相关的判断
- 高手帮帮忙,刚刚学习php帮忙解释一下这段代码 多半地方都看不明白
- XHProf 分析结果 负数 表示什么意思
- 高手请进
- 那位能解读一下这个程序,很值得学习,可是不知道为什么不能正常工作?
- 今天看了一道数学题,不明白是什么意思,请大家帮忙解决
- print <<<EOT 出现提示Parse error: syntax error, unexpected $end in 如何解决?
- 老程序员请进!急急急!PHP能否自动发送POST表单(到另外一个网站)(目的获取表单处理页面处理表单后的显示内容)?必须POST方式
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6224 bytes) in E:\wamp\www\simple.php on line 273不知什么原因?
我时说你的写法是有语法错误的,正确的应该是$upload_file = "my.".$file_ext;现在的错误应该是超过了最大允许内存大小。
修改下memory_limit
ini_set('memory_limit',20M);
或者更大
memory_limit
这个在哪修改?