2016-05-03 87 views
1

我正在將圖片圖片上傳到我的服務器。 我使用以下腳本:將圖片上傳到服務器時無法打開流

<?php 
include("mysqlconnect.php"); 

    function GetImageExtension($imagetype) 
    { 
     if(empty($imagetype)) return false; 
     switch($imagetype) 
     { 
      case 'image/bmp': return '.bmp'; 
      case 'image/gif': return '.gif'; 
      case 'image/jpeg': return '.jpg'; 
      case 'image/png': return '.png'; 
      default: return false; 
     } 
    } 



if (!empty($_FILES["uploadedimage"]["name"])) { 

    $file_name=$_FILES["uploadedimage"]["name"]; 
    $temp_name=$_FILES["uploadedimage"]["tmp_name"]; 
    $imgtype=$_FILES["uploadedimage"]["type"]; 
    $ext = GetImageExtension($imgtype); 
    $imagename=date("d-m-Y")."-".time().$ext; 
    $target_path = "images/".$imagename; 


if(move_uploaded_file($temp_name, $target_path)) { 

    $query_upload="INSERT into 'images_tbl' ('images_path','submission_date') VALUES ('".$target_path."','".date("Y-m-d")."')"; 
    mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error()); 

}else{ 

    exit("Error While uploading image on the server"); 
} 

} 

?> 

我有我的代碼的一些問題。我收到多個錯誤。

未能打開流:C中沒有這樣的文件或目錄:\ XAMPP \ htdocs中\ nipu \在線文件上傳\ saveimage.php 29

警告:move_uploaded_file(圖片/ 2016年3月5日-1462289806.jpg):未能打開流:第29行中沒有C:\ xampp \ htdocs \ nipu \ file upload \ saveimage.php中的此類文件或目錄

警告:move_uploaded_file():無法移動'C :\ xampp \ tmp \ phpF912.tmp'到'images/03-05-2016-1462289806.jpg'在C:\ xampp \ htdocs \ nipu \ file upload \ saveimage.php上線29

這裏有什麼問題?

+0

檢查圖像文件夾在正確的位置 – Satya

+0

您是否創建了該文件夾?應用有適當的權限? –

+0

在哪裏創建該文件夾? – strom

回答

0
  1. 設置完整路徑$target_path
  2. 目錄結構檢查目標文件夾存在與否?
  3. 也爲該文件夾設置「寫入」權限。
0

根據你這樣的代碼

-nipu 
--file upload 
---saveimage.php 
---images 
相關問題