Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Uploads - Show images immediately.

Status
Not open for further replies.

Skippie1

Technical User
May 7, 2012
29
ZA
Hi,

I have a PHP script where my members can upload images to my website. How do I make it that once it is uploaded it is showing immediately on that members page. Sort of like a facebook picture upload??
 
How does your script upload?
Do you use a Database?
Can your members page not just load any images it finds?
What's stopping you from showing them?

Help us help you by being a little more descriptive.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Hi,

I am setting up a page where people can advertise there business in my city. Basically I am creating a PHP upload form which load the images directly to the root directory of my webserver. So after they upload a picture I want it to be shown on there page of my website. I am no expert in web designing so the biggest problem is that I don't know how to design it that I can place a sort of an image placeholder on the HTML page and as soon as the member upload a picture it must show it in that position.
 
Well assuming your upload script gives the image a name related to the advertiser in question in some form you can at its most basic build your image filename from the advertiser name, and maybe an image ID, and then check to see if it exists and load it into an img tag, otherwise load a default image:

Code:
<?php
$filename=$advertisername . imgID .".jpg";
if(file_exists($filename))
{
   echo "<img src='" . $filename . "' alt='Advertiser Image'/>";
}
else
{
   echo "<img src='default.jpg' alt='No Advertiser Image'>";
}
?>

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top