Home  >  Article  >  Backend Development  >  Why can't move_uploaded_file() move the uploaded file?

Why can't move_uploaded_file() move the uploaded file?

WBOY
WBOYOriginal
2016-08-10 09:07:201887browse

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.

Why can't move_uploaded_file() move the uploaded file?

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

Reply content:

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.

Why can't move_uploaded_file() move the uploaded file?

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

The second parameter of move_uploade_file is the file path you want to save. Remember, include the file name, include the file name

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn