The Move_upload0ed_file () function returns fewer parameters, but there are many reasons for the error, so it is difficult for beginners to encounter problems.
The cause of the error is about three points:
1. If the detected file is not from post upload, this file will not perform CP work;
2. The destination path cannot be found;
3. Destination path permission non-execution process lesson read and write (this is I found in the afternoon);
First look at these lines of code to understand the environment:
if (Move_uploaded_file ($fileInfo [' Tmp_name '], $destination))
{
$mes = "File upload succeeded";
}
Else
{
$mes = "File move Failed";
}
Result returned file move failed
This afternoon to find a lot of information, probably the following several statements:
1. Should use absolute path, my parameter $destination value is uploads, plus absolute path is/home/llawlite/imooc/shopimoc/test/uploads
Verification is not the problem.
2. The path should be preceded by ROOT, $destination =root. $destination; Verified invalid;
Finally, you can only explore it yourself and find that this is a Linux file permissions issue.
First, the files that are post in the script are placed in the Temp directory (tmp_dir) and then copied to the destination path.
If the destination path does not have permission to write the file, then the function executes with an error.
This afternoon did the following attempt, first change the destination path to/tmp $destination = "/tmp". $fileInfo [' name '], the result function executes successfully.
The comparison found that the permissions of/TMP is DRWXRWXRWX, and my/home permission is drwxr-xr-x, the problem at a glance.
The following changes the permissions of/home Chmod-r 777/home (permissions are changed for all files in the entire directory and subdirectories).
Then the path is changed to the original path, the verification problem has been resolved.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Questions about Move_uploaded_file () error