Page 1 of 1

Selecting an uploaded image

Posted: Wed Jul 19, 2006 4:41 am
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

Posted: Wed Jul 19, 2006 9:46 am
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.

Posted: Wed Jul 19, 2006 10:11 am
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.

Posted: Thu Jul 20, 2006 3:56 am
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

Posted: Thu Jul 20, 2006 9:11 am
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>