我想将图片上传到文件夹/images
并保留其名称
这就是我得到的:
HTML
<form action="script.php" method="post" enctype="multipart/form-data">
<input type="file" name="mynewimage">
<input type="submit">
</form>
PHP
if (!empty($_FILES['mynewimage']['name'])) {
move_uploaded_file($_FILES['mynewimage']['tmp_name'], "images/" . $_FILES["mynewimage"]["name"]);
}
/ images文件夹是777
错误说:UPLOAD_ERR_NO_FILE
Value: 4; No file was uploaded.
答案 0 :(得分:1)
您应该检查上传错误:
if (isset($_FILES['mynewimage']) && $_FILES['mynewimage']['error']==0) {
....
}else{
die('Error uploading, code '.$_FILES['mynewimage']['error']);
}
检查错误代码here。
答案 1 :(得分:1)
找到它。我的html中有多个<input type="file" name="mynewimage">