Ask the great God to see this code, upload pictures smoothly, but can not find the picture

Source: Internet
Author: User
Ask the great God to see this code, upload the picture successfully, but can't find the picture?




Test the input







$photo _dir= '/var/www/images/';
if (!is_dir ($photo _dir) | | Is_writeable ($photo _dir)) {
Die (' No dir exist or can write ');
}
if ($_files[' picture '] [' ERROR ']>0) {
Echo ' ERROR: '. $_files[' picture ' [' Error ']. '
';
}
else{
echo "Upload:". $_files[' picture ' [' name ']. '
';
echo "type:". $_files[' picture ' [' type ']. '
';
echo "Size:". ($_files[' picture '] [' size ']/1024). ' Kb
';
echo "stred in:". $_files[' picture ' [' tmp_name ']. '
';
if (file_exists ('/var/www/images/'. $_files[' picture '] [' name ']))
{
echo $_files[' picture ' [' name ']. ' already exists ';
}
Else
{
$gpy =move_uploaded_file ($_files[' picture '] [' tmp_name '], '/var/www/images/'. $_files[' picture ' [' name ']);
if (gpy)
{
Echo ' Succed ';
}
Echo ' Stored in: '. ' Images/'. $_files[' picture ' [' name '];
}
}

?>


The code actually shows that the upload was successful, but I can't find the uploaded file in the file path I set?
------Solution--------------------
Do you want to double-check the files that are not actually uploaded under that path?

In addition, open the error prompt function, to see if there are any error messages during the upload process.
------Solution--------------------
Your images directory does not have normal user write permissions
You can view the post-submission page content, there must be no Succed words
------Solution--------------------
References:
Quote: References:

Quote: References:

Directory permissions problem, images folder to Www-data Write permission?

What is the authority you are referring to? I set the/var/www/image to the web, which is what I can read and write, right?


The Web is the user you created yourself, and the Apache username is Www-data
------Solution--------------------
if (gpy)
Obviously wrong.
should be if (
  • 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.