Php uploads images. I have been sleepy for a long time.

Source: Internet
Author: User
Php uploads images. I have been sleepy for a long time. The problem is in the comments of the code.

Run the code first.

I don't think there is a problem with the code on html. I found a lot of cases on the Internet before writing the code. I wrote almost the same as on the Internet.
$ Ifile = $ _ FILES ['c _ photo ']; // The uploadImage ($ ifile) file uploaded from the foreground ); // call method // The method I wrote: function uploadImage ($ file) {$ filepath = "/uploads/photo/accredit/"; // after clicking upload, the folder contains no images. This folder exists. Move_uploaded_file ($ file ["tmp_name"], $ filepath. $ file ["name"]); echo $ file ["tmp_name"]; // upload a jpg image. C: \ wamp \ tmp \ php16F is returned here. tmp (this file is not found in this directory) echo $ file ["name"]; // the image name is returned here, and the image uploaded on it is the same. Echo"
"; Echo $ file ['error']; // Here 0 is returned (0 indicates that the upload is successful )}


Reply to discussion (solution)

$ Filepath = "/uploads/photo/accredit /";
This is the absolute path!
Are your images stored outside the website?

If your upload. php is in the root directory ?,? Sentence to question ??
$ Filepath = dirname (_ FILE _). "/uploads/photo/accredit/"; // after clicking upload, the folder contains no images. This folder exists.

Object ???????
Upload. php
Uploads/photo/accredit/

Is upload. php? Uploads File? Same ?. You again ??.

Thank you. I have already solved the path problem.

Let's take a look at the solution.

I often make mistakes about the path. Clearly, the code is correct, but it cannot.

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.