Ask the great God to see this code, upload the picture successfully, but can't find the picture?

Source: Internet
Author: User
                        Test the input                                        

 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[' pictu Re ' [' 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?


Reply to discussion (solution)

/var/www/images/There's no picture of you uploading here?

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

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.

Post an upload and display content

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?

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.
No, how does the error prompt function open? I just learned PHP.


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?

Your images directory does not have normal user write permissions
You can view the post-submission page content, there must be no Succed words



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

Your images directory does not have normal user write permissions
You can view the post-submission page content, there must be no Succed words
After submitting the file it shows that it is really successful ....

Ordinary users can write? How do you change this?




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
Can Apache users modify it? I am my own environment built with Ubantu Linux, and the code is running locally.

if (gpy)
Obviously wrong.
should be if ($gpy)
So your judgment is wrong and it's normal to go inside if.
Open all tips for PHP. The images should not have write permission.

if (gpy)
Obviously wrong.
should be if ($gpy)
So your judgment is wrong and it's normal to go inside if.
Open all tips for PHP. The images should not have write permission.

Now I have changed the permissions, the file path began to error? How should the file path be written?





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
Can Apache users modify it? I am my own environment built with Ubantu Linux, and the code is running locally.
No, why do you change it, you give images directory attached Www-data Write permission not to be finished?

The error message is posted.
Another glance at your code:
if (!is_dir ($photo _dir) | | Is_writeable ($photo _dir))
This is a logic error.
should be if (!is_dir ($photo _dir) | |! Is_writeable ($photo _dir))

The error message is posted.
Another glance at your code:
if (!is_dir ($photo _dir) | | Is_writeable ($photo _dir))
This is a logic error.
should be if (!is_dir ($photo _dir) | |! Is_writeable ($photo _dir))
Haha, too sloppy, but I have to delete the previous if judgment, I hope through the $_files[' picture ' [' Error '] prompt error message, but still 0, that is, there is no writable problem






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
Can Apache users modify it? I am my own environment built with Ubantu Linux, and the code is running locally.
No, why do you change it, you give images directory attached Www-data Write permission not to be finished?
The wrong point, made to throw bricks ... But with $_files[' name ' [' Error '] should be able to indicate whether the error is caused by the write, but this hint is still 0, that is, success, this is how


Error prompt posted.
In addition, a glance at your code:
if (!is_dir ($photo _dir) | | Is_writeable ($photo _dir))
This is a logic error. The
should be if (!is_dir ($photo _dir) | |! Is_writeable ($photo _dir))
Haha, too sloppy, but I have the previous if judgment all deleted, I hope through the $_files[' picture ' [' Error '] prompt error message, but still 0, that is, there is no writable problem
$_files[' picture ' [' Error '] gives an upload error, and now your problem is that the upload was successful and the Move_uploaded_file process failed.

!--? php
$photo _dir= ' images/';
if (!file_exists ($photo _dir))
{
mkdir ($photo _dir);
}

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 ']. '
';
echo "error:". $_files[' picture ' [' Error ']. '
';
if (file_exists ('/var/www/images/'. $_files[' picture '] [' name ']))
{
echo $_files[' picture ' [' name ']. ' already exists ';
}
Else
{
$gpy =move_uploaded_file ($_files[' picture '] [' tmp_name '], $photo _dir.$_files[' picture '] [' Name ']);
if ($gpy)
{
echo ' Succed '. '
';
}
Echo ' Stored in: '. ' /var/www/images/'. $_files[' picture ' [' name '];
Echo ';
}
}

?>



The error message is posted.
Another glance at your code:
if (!is_dir ($photo _dir) | | Is_writeable ($photo _dir))
This is a logic error.
should be if (!is_dir ($photo _dir) | |! Is_writeable ($photo _dir))
Haha, too sloppy, but I have to delete the previous if judgment, I hope through the $_files[' picture ' [' Error '] prompt error message, but still 0, that is, there is no writable problem
$_files[' picture ' [' Error '] gives the upload error, now your problem is the upload success, move_uploaded_file process failed.

It's finally done,
if (!file_exists ($photo _dir))
{
mkdir ($photo _dir);
}
is to refer to someone else's code, add this line of code, but it is very strange, and did not create a new images file, the previously uploaded files are suddenly displayed ...

  • Related Article

    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.