2011-02-14 94 views
0

大家好 在我的PHP的网站我有一个脚本上传图片,请参见下面文件允许PHP上传图像

$uploaddir = $root_path."images/uploaded_images/category/"; 
      $small_file_name = trim($_FILES['cat_image1']['name']); 
      $small_file_len = strlen($small_file_name); 
      $small_file_ext = strtolower(substr($small_file_name,-4)); // select last 4 characters 
      $small_uploadfile = $uploaddir. $_FILES['cat_image1']['name']; 
      if($small_file_len>4 and ($small_file_ext==".gif" or $small_file_ext==".jpg" or $small_file_ext=="jpeg")){ 
       if ($small_file_ext=="jpeg") 
        $uniqname = uniqid(rand()).".".$small_file_ext; 
       else 
        $uniqname = uniqid(rand()).$small_file_ext; 
       $thumb_filename1 = "thumb_".$uniqname; // store uniqname into database 
       $uploadfile = $uploaddir.$uniqname; //uncomment for local testing 
       if (move_uploaded_file($_FILES['cat_image1']['tmp_name'], $uploadfile)) { 
        chmod($uploadfile,0777); 
        list($width, $height, $type, $attr) = getimagesize($uploadfile); 
        $max_width = 276; 
        $max_height = 162; 
        $a = new Thumbnail($uploadfile,$max_width,$max_height,$uploaddir.$thumb_filename1,100,''); 
        $a->create(); 

       }else{ 
         $flag=1; 
         $frm_server_side_error= $frm_server_side_error."Error in uploading image,"; 
       } 
      } 
      else{ 
       $flag=2; 
       $frm_server_side_error= $frm_server_side_error."Image not in gif or jpg format,"; 

      } 

脚本上传到其无法看到服务器后(我显示拇指图像)。所以我通过FTP检查了该映像的文件权限并给予了读取权限。因此图像显示。但是我将读写权限授予了分类文件夹,并且它是父文件夹。上传后如何查看图像(默认读取权限,上传文件,即拇指图像。) 我注意到,实际图像具有读取权限,但拇指图像没有读取权限。我只需要显示拇指图像。请帮我

在此先感谢

+0

服务器运行的是什么操作系统? – seanieb 2011-02-14 06:36:10

回答

1

您已使用类缩略图创建缩略图图像。但我想你错过了在新的缩略图中更改文件权限。请检查该类的create()函数中的代码缩略图

0

你格式化这里不好(一半是在代码格式,有一半没有),但它似乎你将文件从临时位置复制到段之前的注释代码最后的位置 - 如果是这样的话,文件将不存在,因此将不可见。

但我可能是错的 - 我很高兴再次看看,如果你修复格式。