doudilin1225
2016-09-21 00:49
浏览 35
已采纳

从PHP上传获取途径

I have looked around for a solution and have found several of the same brand, but I can't seem to get an exact solution.

I want the image to display, which, in some sense works-partly. It uploads, but no image is displayed. What is the meaning of this?

Here is my PHP code:

<?php
echo <<<_END
<html><head><tite>PHP Form Upload</title></head><body>
<form method='post' action='login.php' enctype='multipart/form-data'>
Select file: <input type ='file' name='filename' size='10'/>
<input type='submit' value='upload'/>
</form>
_END;
if($_FILES){
$name = $_FILES['filename']['name'];
move_uploaded_file($FILES['filename']['tmp_name'],$name);
echo "Uploaded image '$name' <br /> <img src='$name' />"; 
echo "pathway " . $_FILES['filename']['tmp_name'];
}
echo "</body></html>";
?>

Here is my error:

Failed to load resource: the server responded with a status of 404 (Not Found)

Logically, this doesn't make sense to me since when the page is uploaded, my code redirects to the same page and uploads the image with the correct pathway from tmp_name. Well let me know guys

This is what it looks like on the client-side: enter image description here

You cna try it here: http://danny4help.com/login.php

图片转代码服务由CSDN问答提供 功能建议

我已经四处寻找解决方案并找到了几个相同的品牌,但我似乎无法获得 确切的解决方案。

我想要显示图像,从某种意义上说,这部分是有效的。 它上传,但没有显示图像。 这是什么意思?

这是我的PHP代码:

 &lt;?php 
echo&lt;&lt;&lt; _END 
&lt; html&gt;&lt;  ; head&gt;&lt; tite&gt; PHP表格上传&lt; / title&gt;&lt; / head&gt;&lt; body&gt; 
&lt; form method ='post'action ='login.php'enctype ='multipart / form-data'&gt;  
选择文件:&lt; input type ='file'name ='filename'size ='10'/&gt; 
&lt; input type ='submit'value ='upload'/&gt; 
&lt; / form&gt; 
_END  ; 
if($ _ FILES){
 $ name = $ _FILES ['filename'] ['name']; 
move_uploaded_file($ FILES ['filename'] ['tmp_name'],$ name); 
echo“已上传 image'$ name'&lt; br /&gt;&lt; img src ='$ name'/&gt;“;  
echo“途径”。  $ _FILES ['filename'] ['tmp_name']; 
} 
echo“&lt; / body&gt;&lt; / html&gt;”; 
?&gt; 
   
 
  

这是我的错误:

无法加载资源:服务器响应状态为404(未找到)

逻辑上,这 对我来说没有意义,因为当页面上传时,我的代码会重定向到同一页面,并使用tmp_name中的正确路径上传图像。 好吧,让我知道伙伴们

这就是客户端的样子:

你可以在这里试试: http://danny4help.com/login.php

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dougou6727 2016-09-21 02:21
    已采纳

    your move_uploaded_file($FILES['filename']['tmp_name'],$name); should be move_uploaded_file($_FILES['filename']['tmp_name'],$name); .

    Underscore is missing.

    点赞 评论

相关推荐 更多相似问题