The following source code in Windows Apache can normally upload files, but in Ubuntu Linux will not error, but upload files can not go to the specified directory.
Ask you how to solve.
Thank you!
$ErrorMessage =null;
$Message =null;
if (!empty ($_files[' Filefield ' [' name '])) {
if ($_files[' Filefield ' [' Error ']>0) {
$ErrorMessage = ' ERROR: ' $_files[' Filefield ' [' Error '];
}else{
if (Is_uploaded_file ($_files[' Filefield ' [' tmp_name '])) {
Transferring files
Move_uploaded_file ($_files[' Filefield ' [' Tmp_name '],
'/var/www '. ' /'. $_files[' Filefield ' [' name ']);
$Message = ' Upload successful! ';
}else{
$ErrorMessage = ' Error: '. ' Upload failed! ';
}
}
}
?>
Reply to discussion (solution)
It's a privilege problem. Change the upload directory to 777 test.
Windows is a single-user operating system and rarely encounters permissions issues. Even on the server, due to Microsoft's strong team, there are very few permissions problems
Linux is a multi-user operating system (even if you're the only one using it), so the permissions problem is everywhere. Open source projects have not been weak technical support, so far there is no simple and quick tool
Move_uploaded_file will determine whether to upload files, is_uploaded_file multiple times
Move_uploaded_file will return an error state when it encounters a directory that does not exist, is not writable, and does not have enough space.
And you do not discriminate on the $Message = ' upload success! '; It's not proper.
In the program the most? Plus
Ini_set (' display_errors ', ' on ');
Error_reporting (E_all);
What do you know when you're done? , which is usually a document?? Limit??
Commands can be used on Linux? side
The file?? It's www-data.
CHGRP Www-data Folder
And then? Limit
chmod g+rw Folder
Open the error prompt to see
'/var/www '. ' /'. $_files[' Filefield ' [' Name ']
Post Directory file permissions
Thank you very much, indeed is the authority question, the revision is good.
Thank you