2015-02-09 591 views
3

我將2張圖片存入我的數據庫。如果我一次上傳2張圖片,那麼它的存儲成功。但是,如果嘗試上載僅此搜索,或者如果我嘗試上傳圖像2或者,如果我沒有上傳任何圖片,然後我得到這個警告上傳圖片時文件名不能爲空

警告:file_get_contents()函數[function.file-GET-內容]:文件名不能在C空:\瓦帕\ WWW \上線打印\ main.php 24

我的代碼是:

<label for="certificate">Upload Scaned Document:</label> 
    <input type="file" name="image" /> 
       OR 
    <label for="certificate">Upload Scaned QR Code</label> 
    <input type="file" name="QRimage" /> 

PHP代碼:

$imageName = mysql_real_escape_string($_FILES["image"]["name"]); 
    $imageData = mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"])); 

    $QRimageName = mysql_real_escape_string($_FILES["QRimage"]["name"]); 
    $QRimageData = mysql_real_escape_string(file_get_contents($_FILES["QRimage"]["tmp_name"])); 

即使我試圖與這一切都如此:

if(isset($_FILES["image"]) && (!empty($_FILES["image"])) && ($_FILES['image']['error'] == 0)) 

而且

if((isset($_FILES["QRimage"]["size"])) && ($_FILES["QRimage"]["size"] > 0)) 

然後我可以克服警告。

如果我試圖上載Image1那麼。

  Notice: Undefined variable: QRimageName in C:\wamp\www\print\main.php on line 59 
     Notice: Undefined variable: QRimageData in C:\wamp\www\print\main.php on line 59 

如果我試圖上傳Image2那麼。

  Notice: Undefined variable: imageName in C:\wamp\www\print\main.php on line 59 
     Notice: Undefined variable: imageData in C:\wamp\www\print\main.php on line 59 

我養活了這個錯誤,請幫助我如何解決這一

回答

2

試試這個,

​​
+1

喲。其作品:)謝謝:) – Nayana 2015-02-09 11:44:54