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
Selecting an uploaded image
Moderator: General Moderators
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.
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.
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.
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>