Jump to content

Recommended Posts

On an auction listing page im making the user who has uploaded their listings' info can also upload a photo.

on the page "listing.php?&id=***" their listing is auto-generated from mysql. part of this auto generated info is an image. As a user can only upload one photo, and their user ID is unique, the html to display this message is:

 

../images/thumbs/$username.jpg

 

Problem:

 

If they chose not to upload a photo with the listing that ugly broken image symbol is displayed. How can i hide this or have an auto

____________________

|                              |

|        NO                |

|      IMAGE              |

|    UPLOADED            |

|                              |

|___________________|.jpg type file that is default outputed.

 

Thanks for any answers

 

~bionic25

 

 

Link to comment
https://forums.phpfreaks.com/topic/119823-help-with-missing-images/
Share on other sites

The way I would be tempted to do this would be:

 

When the user signs up in your form handler, check that the image upload isn't empty, and save their image path to the database if it isnt. If it is replace their path with a default one.

 

Hope this helps?

Thanks for the posts they are both solutions. I tried the file_exist one, which seems to fit exactly what I need.

this is the new code:

			if(file_exists("..newCar/thumbs/$username.jpg")) {
				echo "<img src=\"..newCar/thumbs/$username.jpg\">;
			}
			else{
			echo "no image";
			}

 

problem is, for some reason, when i tested it it will only output "no image" even though the file DEFINITELY exists?!

 

Im new to php so may be problem in code, any ideas??

		
	                if(file_exists("/***/***/****/*/*/******/public_html/******/images/thumbs/$username.jpg")) {
				echo "<img src=\"..newCar/images/thumbs/$username.jpg\">";
			}
			else{
			echo "no image";
			}

 

Right, tried that ^^ but now the entire page isn't working!! I tried removing this section and it worked again?! What is wrong with this code it is confusing the hell out of me, but im sure its a code error (newbie php'er)

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.