2012-03-20 88 views
0

我一直在敲打我的頭靠在牆上,試圖找出這個問題,我所要做的是PHP文件上傳不updaing數據庫或上傳文件

  • 檢查,看是否像文本框爲空或不
  • 查看文件是否是JPG或PJPEG,如果不返回無效圖像
  • 看看是否有任何錯誤
  • 如果出現錯誤,顯示錯誤,如果不能上傳文件,然後更新數據庫...

這裏是我的情況:

case"updatesubmit": 
    if ($_FILES['image']['error'] === UPLOAD_ERR_OK) { 

     if (($_FILES["image"]["type"] == "image/jpeg") || ($_FILES["image"]["type"] == "image/pjpeg")){ 
      if ($_FILES["image"]["error"] > 0){ 
       echo $_FILES["image"]["error"]; 
      }else{ 
       move_uploaded_file($_FILES["image"]["tmp_name"], 
       "../upload/CV_1_" . date("Ymd") . $_FILES["image"]["name"]);  
       $class->update($id, $text, $image); 
       echo "<div style='padding-left:50px'><strong>Updated!</strong></div>"; 
      } 
     }else{ 
      echo "<div style='padding-left:50px'><strong>Invalid Image!</strong></div>"; 
     } 
    }else{ 
     $class->updateWithoutImage($id, $text); 
     echo "<div style='padding-left:50px'><strong>Updated!</strong></div>"; 
    } 
     $array = $class->view(); 
     include("view/CV/view_display.html"); 
    break; 

如果任何人都可以在正確的方向指向我,這將是真棒!

+0

你有什麼問題?你只詳細說明你想做什麼,而不是錯誤 – JackTurky 2012-03-20 20:48:25

+0

當我上傳文件時,我得到無效圖像!返回 – user1274810 2012-03-20 20:50:32

回答

0

,你可以用這種方式編輯代碼:

list($width, $height, $type, $attr) = getimagesize($_FILES['image']['tmp_name']); 
if($type!=2){ // SO IS NOT JPG 
//ERROR 
} 
+0

這是我的php5.ini – user1274810 2012-03-20 21:07:51