Home > Article > Backend Development > Why can't move_uploaded_file() move the uploaded file?
send.php
<code><form action="receive.php" method='post' enctype='multipart/form-data'> <input type="file" name='upload' /> <input type="submit" value='上传' /> </form></code>
receive.php
<code><?php echo $_FILES['upload']['error']; if(!move_uploaded_file($_FILES['upload']['tmp_name'],'/')) {echo 'y';}; ?></code>
Please look at the code of the above two files, send.php uploads the file to receive.php
I uploaded a picture, the upload was successful, but the move failed. The picture below is the prompt.
What’s the reason? How to solve it?
Thank you
p.s I am using a local server built by phpstudy. Win8.1 x64, some people say that the permissions are not enough, how can I increase the permissions? Thank you
send.php
<code><form action="receive.php" method='post' enctype='multipart/form-data'> <input type="file" name='upload' /> <input type="submit" value='上传' /> </form></code>
receive.php
<code><?php echo $_FILES['upload']['error']; if(!move_uploaded_file($_FILES['upload']['tmp_name'],'/')) {echo 'y';}; ?></code>
Please look at the code of the above two files, send.php uploads the file to receive.php
I uploaded a picture, the upload was successful, but the move failed. The picture below is the prompt.
What’s the reason? How to solve it?
Thank you
p.s I am using a local server built by phpstudy. Win8.1 x64, some people say that the permissions are not enough, how can I increase the permissions? Thank you
Windows systems can almost ignore permissions
The second parameter of move_upload_file is the file name, not the path
http://www.php.net/manual/zh/...
The destination path to move to is written incorrectly. .
The second parameter of move_uploaded_file is the mobile address. Your code is obviously a Linux-style path root directory/. If it is windows, please write it in the form D:www
It is recommended to check the manual before asking such questions
The second parameter is wrong. Specify the folder path. If it is Linux, set the write permission of the folder.
The error message is written so clearly for you
The second parameter cannot be a directory, but the full path must be written, including the file name.