0

I am trying to fetch an image from a local directory and would love to allow the user a preview before uploading the picture to the server; so my question is will I be able to extract the exact directory of the image from the $_FILES variable instead of its "tmp_name" since I could not use the "tmp_name" value as src=" " for the HTML "IMG" tag;

thanks in advance!

  • When you upload an image from a web form, this image gets uploaded to the server and php saves it in the temporary directory provided by `tmp_name`. You need to use `move_uploaded_file` to move the temporary file inside your webserver directory so that it can be used in the SRC of your HTML – Andrea Olivato Jun 27 '21 at 13:14
  • 1
    The phrase “before uploading the picture to the server” really implies client side which is [really easy](https://stackoverflow.com/a/4459419/231316). Otherwise, you need to handle uploads normally in PHP, but you could handle the preview with AJAX – Chris Haas Jun 27 '21 at 13:14

0 Answers0