doujiao4705 2013-04-06 05:00
浏览 86

$ _FILES给出找不到对象(html代码已完成)

I've Googled my problem but can't fix it (I'm new to PHP), the $_FILES function gives me 'Object not found...', the following is the simple code:

<?php 

echo <<<_END

<html><head><title>Upload Test</title></head><body>
<form method='post' action='upload.php' enctype='multipart/form-data'>
Select File: <input type='file' name='filename'  />
<input type='submit' value='Upload' />
</form>
_END;

if ($_FILES){

$fname = $_FILES['filename']['name'];
move_uploaded_file($_FILES['filename']['tmp_name'], $fname);
echo "<img src='$fname' />";

}
echo "</body></html>";

?>

When I hover the mouse over a link in the error message, I see that the file name is interpreted as:

http://127.0.0.1:8080/file%2520uploading%2520-%2520CODE%2520PROBLEM%2520ASK%2520!.php

I don't have enough reputation to give a screenshot of the error, so here's the important part of it: "The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated." The words 'referring page' of the error message is a hyperlink that displays the file name mentioned just above (when I hover the mouse over that link).

To me, $fname as destination seems ok, can anyone tell me what is wrong with the code? I've also tried reading an error code but run into more problems that way, so I'm keeping the code simple.

Supporting details:

I'm testing the code on my laptop (Windows 7) which has my WAMP installation (from EasyPHP)

Thanks very much in advance.

  • 写回答

1条回答 默认 最新

  • dougu6815 2013-04-06 05:23
    关注

    See this link..http://www.w3schools.com/php/php_file_upload.asp.. This will show image uploading helpfully...

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致