我在php mysql中上传图片时遇到致命错误

时间:2013-02-28 14:52:54

标签: php

我在

输入图片
<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.');
          }
     }

这给了我致命的错误..

1 个答案:

答案 0 :(得分:0)

您可能忘记在表单中放置enctype="multipart/form-data",这会阻止文件上传。结果$_FILES为空,您收到了该错误。