Jump to content
Larry Ullman's Book Forums
Sign in to follow this  

Chapter 19 Adding Images To The Uploads Folder

Recommended Posts

For some reason the images I am uploading to my uploads folder are just showing as blank, the files are there but it is not showing them as images. It is written that the type of file it is is just File. and it shows the path to the image D:\xampp\htdocs\uploads.

My add_print.php is just fine as far as I can tell. I tested it with the script written by Larry in the working files for this book, it doesn't work either. I checked my permissions for my uploads folder and they look fine too. 


I am thinking the problem is maybe because no Mime type is specified for the images being uploaded. If that isn't where the error is, it is maybe in the code below, where my uploads folder is. it is specified as ../../../uploads. any help would be appreciated.


if (is_uploaded_file($_FILES['image']['tmp_name'])){
$temp = '../../../uploads/' . md5($_FILES['image']['name']);
if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)){
echo '<p>The file has been uploaded!</p>';
$i = $_FILES['image']['name'];
or could the problem be below:?
if (mysqli_stmt_affected_rows($stmt) == 1){
echo '<p>The print has been added.</p>';
$id = mysqli_stmt_insert_id($stmt);
rename ($temp, "../../../uploads/$id");
$_POST = array();


Share this post

Link to post
Share on other sites

That's all fine, because the images won't be accessed through the file system, but rather through a proxy script that will also provided the MIME type to the browser.

Share this post

Link to post
Share on other sites

There could be several reasons why. To debug it, you'll want to take the src value for the img (from the browser HTML source) and run that directly in a browser to see what, if any, PHP error is reported. 

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...