Questions about uploading images to PHP. Trapped my little brother for a long time

Source: Internet
Author: User
Problems with uploading images in PHP. Trapped me for a long time.
The problem is that it's in the code comment .

First, the code.

HTML on the code first, I feel no problem, write code before I found a lot of cases on the Internet, I wrote and online almost the same.


$ifile =$_files[' C_photo ']; The documents sent by the front desk
Uploadimage ($ifile); Calling methods



The way I wrote it.
function Uploadimage ($file) {

$filepath = "/uploads/photo/accredit/"; There are no pictures in the folder after the point upload. The folder is present.


echo $file ["Tmp_name"]; Upload is a JPG image, here is the return of C:\wamp\tmp\php16F.tmp (to see the next directory without this file)
echo $file ["name"]; Here is the name of the picture, the image I uploaded is the same.
echo "
";
echo $file [' Error ']; The return is 0, (0 means upload is successful)

}


------Solution--------------------
$filepath = "/uploads/photo/accredit/";
This is the absolute path!
Is your picture saved outside of the website?
------Solution--------------------
If your upload.php is in the root catalogue, this sentence changes to this
$filepath = DirName (__file__). " /uploads/photo/accredit/"; There are no pictures in the folder after the point upload. The folder is present.

The project should be like this.
upload.php
uploads/photo/accredit/

upload.php is the same layer as the Uploads file folder. You try again.

------Solution--------------------
Path problem, I often make mistakes, obviously the code is not wrong, is not.
  • 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.