Jump to content
Larry Ullman's Book Forums

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();

 

Link to comment
Share on other sites

  • 5 years later...

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. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...