【发布时间】:2020-10-18 00:58:21
【问题描述】:
这是我的表单代码:
<form method='POST' enctype="multipart/form-data">
<input type='file' name='newPicture'>
<button type='submit' name='submit' id='uploadPicBtn'>Upload Photo</button>
</form>
这是我的 php 代码:
<?php
if (isset($_POST['submit'])) {
if (isset($_FILES['newPicture'])) {
$file = $_FILES['newPicture'];
$serverpath = "images/".$file['name'];
move_uploaded_file($file['tmp_name'], $serverpath);
}
}
?>
它们都在同一个 .php 文件 (index.php) 中。
我收到此错误: 警告:move_uploaded_file(images/anime.jpg):打开流失败:第 7 行的 C:\xampp\htdocs\account-settings\index.php 中没有这样的文件或目录
警告:move_uploaded_file(): Unable to move 'C:\xampp\tmp\phpB4E0.tmp' to 'images/anime.jpg' in C:\xampp\htdocs\account-settings\index.php on line 7
怎么了?
【问题讨论】:
-
你测试过指定的目录确实存在吗?
标签: php html forms file-upload