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.