PHP $_files uploads files under Windows Normally, but cannot upload files under Ubuntu

Source: Internet
Author: User
PHP $_files upload files under Windows Normal, but cannot upload files under Ubuntu
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! ';
}
}

}
?>
------Solution--------------------
It's a privilege problem. Change the upload directory to 777 test.
------Solution--------------------
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.

------Solution--------------------
At the top of the program plus
Ini_set (' display_errors ', ' on ');
Error_reporting (E_all);

When you run, you know what's wrong, and it's usually the folder permissions.

Commands can be used at Linux end
Setup file folder user is Www-data
CHGRP Www-data Folder

And then set the limits.
chmod g+rw Folder

------Solution--------------------
Open the error prompt to see
------Solution--------------------
'/var/www '. ' /'. $_files[' Filefield ' [' Name ']
Post Directory file permissions
  • 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.