本文介绍了无法在php中上传图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是PHP新手.我正在尝试使用php上传图片.但这是行不通的.请帮忙.预先感谢
I am new to PHP. I am trying to upload image using php. But it is not working. Please help. Thanks in advance
<?php
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
?>
<form action="upload.php" method="post" >
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
推荐答案
在您的表单中,您缺少enctype
In your form you are missing enctype
<form action="upload.php" method="post" enctype="multipart/form-data">
这篇关于无法在php中上传图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!