以下代码麻烦帮改正,最好加上注释,谢谢!
<?
$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);
}
}
}

解决方案 »

  1.   

     $upload_file = my.".".$file_ext;   这个怎么回事?$upload_file = "my.".$file_ext; 
      

  2.   

    我已经调试到可以上传并等比例缩小了 ,但上传略微大点的图片就显示:
    Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6224 bytes) in E:\wamp\www\simple.php on line 273不知什么原因?
      

  3.   

    内存超了 ini_set('memory_limit','128M');
      

  4.   


    我时说你的写法是有语法错误的,正确的应该是$upload_file = "my.".$file_ext;现在的错误应该是超过了最大允许内存大小。
    修改下memory_limit
    ini_set('memory_limit',20M);
    或者更大
      

  5.   


    memory_limit
    这个在哪修改?