Uploading files to a tmp folder, now trying to display them


I am pretty new at PHP and I have a question.

I have been uploading files (images & txt) to a tmp directory using “move_uploaded_file($_FILES[$filename][‘tmp_name’]…”. I renamed the files according to the uploaded id in my database (auto inc.).

Now I want to display the images/files, which have been renamed.

How do I go about doing that? I understand it has something to do with the MIME type, but I can’t seem to find the right search for it.


I update the file:

// Update the Files table.
$query1 = “UPDATE uploads SET
file_name=’{$_FILES [$filename][‘name’]}’,
WHERE upload_id=$uid”;
$result1 = mysql_query($query1);

               // Report on the success.
               if ($result1) {	
           			 // Move the file over.
		               if (move_uploaded_file($_FILES[$filename]['tmp_name'], "C:/tmp/uploads/$uid")) {
		                   echo '<p><font color="red">The File has been edited!</font></p>';
		               } else { // File could not be moved.
		                   echo '<p><font color="red">The File could not be edited.</font></p>';
		                   // Remove the record from the database.
		                   $query = "DELETE FROM uploads WHERE upload_id = $uid";
		                   $result = mysql_query ($query); 
		                   // Add more detailed error reporting, if desired.

               } else {
                   echo '<p><font color="red">Your submission could not be processed
                     due to a system error. We apologize for any
                     inconvenience.</font></p>';	// Print queries and use the mysql_error() function (after each mysql_error() call) to debug.

Now I want to display the file that has been updated.

How do i go about doing that?

How are you viewing it BEFORE the upload? Perhaps all you need to do is refresh the page?

Not enough info to answer the question.


Thanks for the reply, I found what I needed.

This code resizes the image, therefore it is sort of refreshes the updated image to display.


Sponsor our Newsletter | Privacy Policy | Terms of Service