2011-02-14 122 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

你格式化這裏不好(一半是在代碼格式,有一半沒有),但它似乎你將文件從臨時位置複製到段之前的註釋代碼最後的位置 - 如果是這樣的話,文件將不存在,因此將不可見。

但我可能是錯的 - 我很高興再次看看,如果你修復格式。