Displaying temporary images with php

Hi Guys,

I am creating an online auction script and when users upload images I want them to be able to view the image from within the tmp folder before I move the image to its final location.

The uploaded image is stored here: $_FILES[‘image’][‘tmp_name’] but how do I display that image and how long is it kept?

Just use a simple HTML block to show the image before you move it.

What do you mean by HTML block?

You can’t directly show the image because it’s outside public_html directory. You could use readfile() to output the image. But note that the time of image kept in tmp directory is indeterminable.

hmmm can’t seem to get it working using readfile. Would I use something like this?


You need to read it, send the appropriate header() info then display at via the HTML <img> tag. Thus your PHP file for reading the image needs to be a separate file from the page containing the <img> tag.