Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I show an image on a page, after user uploads it?

Participant ,
Apr 28, 2009 Apr 28, 2009

Hi,

I have a succesful upload form that will upload an image to the specified folder like it is suppose to, but I just can not figure out how to have the image display on another page after someone uploads it. If you want to look yourself, the upload page is located at http://cwhazzoo.com/uploadart.php

and the page I want the art to display in is http://cwhazzoo.com/avatarfanart.php

***you will need a username and password to access pages, I have set up a temporary username and password for those that wish to see the pages. Username: adobehelp Password: 12345

Its seems like it should be simple, but I have no idea. I would be very grateful to those that can help me with this, and I know it is possible, otherwise how could blogs, and other sites (youtube) be able to display someones profile pic right after they upload it.

Thanks!


feel free to e-mail me at webmaster@cwhazzoo.com

TOPICS
Server side applications
567
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 28, 2009 Apr 28, 2009

U can try to put an image placeholder on that page and link it to your folder where u store the image. Are you trying to display a single image or image thumbnails?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 28, 2009 Apr 28, 2009

I am trying to display multiple image thumbnails.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2009 Apr 29, 2009
LATEST

There are several ways to do this, depending on what you actually want to do.

If you want to display all images in the selected folder, you need to use PHP file system functions to loop through the folder, identify all the images, and store them in an array. Then loop through the array to display the images. If your server supports PHP 5, you can use scandir() to examine the contents of the folder. If you're still on PHP 4, the scandir() page in the PHP manual explains how to use opendir() as an alternative.

If you want to display only the image that has just been uploaded, use a session variable to capture the file name, and use that to display the image.

The other way is to store details of the images and who they belong to in a database, and use that to display the images you want.

Whichever approach you adopt, you need to be careful that the images being displayed on your site are not obscene or stolen from other sources. Allowing others to upload files to your server opens you to a lot of security risks that need to be taken into consideration when coding.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines