Jump to content

PHP and Images


stublackett

Recommended Posts

Hi,

 

I've got images uploaded into a Database

What I'd like to know is how you use PHP to manipulate showing "No Image" or something of that sort into a web page

 

The user can add 2 images to a page, But the usual scenario is a second image doesnt get uploaded, So its leaving me with the IE [x] what I'd like to do is replace that with a possible new image

 

Is there any PHP Tutorials / Classes or anything of that sort you can point me towards to help me achieve this?

Cheers

Link to comment
https://forums.phpfreaks.com/topic/117149-php-and-images/
Share on other sites

First you'll need to check if the image exists. If it does, display it, and if not, display a generic non-image.

 

if(file_exists('images/your_directory/your_image.jpg')){
    echo '<img src="images/your_directory/your_image.jpg" />';
}else{
    echo '<img src="images/your_directory/non_image.jpg" />';
}

Link to comment
https://forums.phpfreaks.com/topic/117149-php-and-images/#findComment-602614
Share on other sites

First you'll need to check if the image exists. If it does, display it, and if not, display a generic non-image.

 

if(file_exists('images/your_directory/your_image.jpg')){
    echo '<img src="images/your_directory/your_image.jpg" />';
}else{
    echo '<img src="images/your_directory/non_image.jpg" />';
}

Thank you Xurion

 

I suppose the same logic works for an MySQL Database and set Variables ?

Link to comment
https://forums.phpfreaks.com/topic/117149-php-and-images/#findComment-602630
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.