2013-02-28 73 views
-1

我在我得到致命錯誤,而在PHP的MySQL上傳圖片

<input type="file" name="uploaded_files[]" id="input_clone" multiple="multiple" /> 

以.php我使用這樣

Error: the XML response that was returned from the server is invalid. 
Received: 
<br /> 
<b>Warning</b>: Invalid argument supplied for foreach() in <b>C:\xampp\htdocs\olam\classes\class.xajax.php</b> on line <b>1135</b><br /> 
<br /> 
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\olam\classes\class.xajax.php:1135) in <b>C:\xampp\htdocs\olam\components\xajax\xajax.inc.php</b> on line <b>678</b><br /> 
<?xml version="1.0" encoding="utf-8" ?><xjx><cmd n="js"><![CDATA[xajax.loadingFunction();]]></cmd><cmd n="js"><![CDATA[document.location.replace('?p=complete');]]></cmd><cmd n="js"><![CDATA[xajax.doneLoadingFunction();]]></cmd></xjx> 
echo $_FILES['uploaded_files']['name']; 
    foreach($_FILES['uploaded_files']['name'] as $key=>$value) 
    { 
      if(is_uploaded_file($_FILES['uploaded_files']['tmp_name'][$key]) && $_FILES['uploaded_files']['error'][$key] == 0) 
      { 

       $filename = $_FILES['uploaded_files']['name'][$key]; 


       if(move_uploaded_file($_FILES['uploaded_files']['tmp_name'][$key], 'uploads/'. $filename)) 
       { 


       } 
       else 
       { 
         die ('There was a problem uploading the pictures.'); 
       } 
      } 
      else 
      { 
      die ('There is a problem with the uploading system.'); 
      } 
    } 

這是給我的輸入圖像致命錯誤..

+0

http://stackoverflow.com/search?q=+Invalid+argument+supplied+for+foreach – hakre 2013-02-28 14:56:10

回答

0

你可能忘了把enctype="multipart/form-data"放在你的表格whi ch正在阻止文件上傳。結果$_FILES是空的,你會得到那個錯誤。

+0

此外,他輸出HTML – 2013-02-28 14:55:11

+1

後使用'header()'這只是錦上添花:) – 2013-02-28 14:55:44

+0

我是在表單中使用enctype =「multipart/form-data」我的代碼http://pastebin.com/HWkMSxU4 – 2013-02-28 15:00:03