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屋!
查看全文