【问题标题】:Geting html in respose with upload file function [closed]使用上传文件功能获取html响应[关闭]
【发布时间】:2013-05-27 06:59:54
【问题描述】:

我的代码
=========ajax.php============

$ide = $_POST['ide'];<br>
$it = $_POST['it'];<br>
$a = $_POST['a'];<br>
<br>
$json_arr = array( <br>
    "id" => "event-icoN",<br>
    "t" => $it,<br>
    "ide" => $ide,<br>
    "w" => "http://www.excellencepro.local/templates/contents/passbook/upload/event-iconi.png"<br>
);

$temp = json_encode($json_arr);
echo $temp;

move_uploaded_file($_FILES["xfile"]["tmp_name"], "upload" / $_FILES["xfile"]["name"]);

问题===============

Ajax 响应==

{"id":"event-icoN","t":"s","ide":"is","w":"http:\/\/www.excellencepro.local\/templates\/contents\/passbook\/upload\/event-iconi.png"}<br />
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: Division by zero in C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php on line <i>25</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0013</td><td bgcolor='#eeeeec' align='right'>680864</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php' bgcolor='#eeeeec'>..\ajax.php<b>:</b>0</td></tr>
</table></font>
<br />
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: move_uploaded_file() [&lt;a href='function.move-uploaded-file'&gt;function.move-uploaded-file&lt;/a&gt;]: Filename cannot be empty in C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php on line <i>25</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0013</td><td bgcolor='#eeeeec' align='right'>680864</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php' bgcolor='#eeeeec'>..\ajax.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0015</td><td bgcolor='#eeeeec' align='right'>682600</td><td bgcolor='#eeeeec'><a href='http://www.php.net/move_uploaded_file' target='_new'>move_uploaded_file</a>
(  )</td><td title='C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php' bgcolor='#eeeeec'>..\ajax.php<b>:</b>25</td></tr>
</table></font>
<br />
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: move_uploaded_file() [&lt;a href='function.move-uploaded-file'&gt;function.move-uploaded-file&lt;/a&gt;]: Unable to move 'C:\wamp\tmp\phpAC99.tmp' to '' in C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php on line <i>25</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0013</td><td bgcolor='#eeeeec' align='right'>680864</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php' bgcolor='#eeeeec'>..\ajax.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0015</td><td bgcolor='#eeeeec' align='right'>682600</td><td bgcolor='#eeeeec'><a href='http://www.php.net/move_uploaded_file' target='_new'>move_uploaded_file</a>
(  )</td><td title='C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php' bgcolor='#eeeeec'>..\ajax.php<b>:</b>25</td></tr>
</table></font>

【问题讨论】:

  • 嗯,你试过什么?什么是问题(如果简短描述)?
  • 当我使用 move_uploaded_file() 我收到这个 html 作为响应

标签: php json image-uploading


【解决方案1】:

您得到的输出是您的 PHP 代码(特别是在 C:\wamp\www\excellencepro\templates\contents\passbook\ajax.php 中)导致的 xdebug 漂亮打印错误。看看第 25 行,那里似乎被零除。

实际问题是这样的:

move_uploaded_file($_FILES["xfile"]["tmp_name"], "upload" / $_FILES["xfile"]["name"]);

您可能想改用"upload/" . [..],因为/ 是除法运算符。所以你除以零;-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-12
    • 2012-05-28
    • 2020-08-19
    • 2011-05-08
    • 2013-12-01
    • 2021-05-28
    • 2016-05-17
    • 1970-01-01
    相关资源
    最近更新 更多