PHP $_files upload files under Windows Normal, but cannot upload files under Ubuntu

Source: Internet
Author: User
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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.