HTML 表单文件上传不上传文件 [英] HTML Form File Uploads doesn't upload file
本文介绍了HTML 表单文件上传不上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尽管所有后端代码都正确,但文件并未上传.我用另一个前端风格的代码测试了后端代码,它运行良好.
Files doesn't get uploaded though all back-end code is correct. I tested the back end code with another front-end styled code and it worked fine.
但在我的前端代码中,它不上传任何文件.我还删除了所有 css 和脚本以找出问题所在.
but in my front end code it doesn't upload any files. I removed all css and scripts as well to figure out the issue.
这是我的简单前端 HTML 表单:
here is my simple front end HTML form :
<form action="upload_handler.php" method="post">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload" name="submit">
</form>
推荐答案
你忘了提到 enctype="multipart/form-data"
<form action="upload_handler.php" enctype="multipart/form-data" method="post">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload" name="submit">
</form>
这篇关于HTML 表单文件上传不上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文