Selecting an uploaded image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Selecting an uploaded image

Post by hame22 »

Hi

I have a website with an online form where a user can publish a news article and upload an image to go with it, this works fine.

However I would also like to give the user the option of selecting an already uploaded image from the online images directory.

Has anyone had any experience in such a method and can give pointers how best to achieve it?

Thanks in advance
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

You need to open the directory that all the pre-uploaded images are in, get all the filenames for the images, then in your page, make a bunch of <img> tags pointing to those images. Probably your best bet for allowing the user to select those images, would be to associate a uniquely named radio button with each image.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

did something very similar to this I just have.

read from the folder (as pickle suggested) I did. Then preload the images I did. Display hyperlinks of all the images I do, on mouse over of the hyperlinks, change a src element of an image I am. Allows for showing of all images this does. Select the image by clicking the link you do.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

thats great thanks

I have produced a pop up box that now lists all images in the directory.

How do I go about putting the chosen images url into the textfield on my online form when clicking the images hyperlink?

thanks in advance
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I assume the text field is on the parent form? if so try something like this:

Code: Select all

<a href="#" onMouseOver="showImage('...')" onClick="opener.document.yourform.textfield.value = 'somefilename.jpg'">somefilename.jpg</a>
Post Reply