indymj
asked on
Allow user to browse hard drive for image file and insert image to a specified form field
I have constructed a form using html and java script. I need code (java script ?) to allow a user who is completing the form to be able to browse their hard drive for an image file. Upon selecting the image file, I need the file to insert in a particilar form field. This should all take place on the client side as I am wanting to distribute this form on CD and or my website. My form has five fields that need to be populated by user selected image files (jpg)
Thanks in advance for your help .... it is greatly appreciated!!
Thanks in advance for your help .... it is greatly appreciated!!
Does this form need to upload the images to the website? If not what does it do with the image addresses.
Hi Indy
does this help
http://javascript.internet.com/miscellaneous/computer-drive-browser.html
The example doesn't work seem to work on this site but if you copy and paste it into your own page it appears to work
Michael
does this help
http://javascript.internet.com/miscellaneous/computer-drive-browser.html
The example doesn't work seem to work on this site but if you copy and paste it into your own page it appears to work
Michael
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SirRoss & Daleoran,
Thanks for your input ! Both of your suggestions work to allow a user to browse their hard drives for an image.
What I need in addition to that is as follows:
once a user has selected an image from their hard drive, it needs to automatically be inserterd into the appropriate "form field" ...... a field I specify in the code. I have constructed the following test code which may explain better:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//
function whatFile() {
window.location= 'file:///' + document.form2.cmuds.value ;
}
// End -->
</script>
</head>
<body>
<div align="center">
</div>
<form name=form1>
<p align="center">
<input border="0" src="../"
name="image1" width="200" height="150" type="image"></p>
</form>
<p> </p>
<p> </p>
<p> </p>
<form name=form2>
<p align="center">
<input type=file name="cmuds" size="30">
<input type=button onClick="whatFile()" value="Open File"> </p>
</form>
</body>
</html>
As you may see, this code opens a browse of the hard drive and allows the user to select an image file. The problem is that when you press the "Open File" button the image opens in another window. I need the image to open in a specified "form field" ..... in this case "form1;image1" Is this possible?
Thanks again for your help!!
indymj
Thanks for your input ! Both of your suggestions work to allow a user to browse their hard drives for an image.
What I need in addition to that is as follows:
once a user has selected an image from their hard drive, it needs to automatically be inserterd into the appropriate "form field" ...... a field I specify in the code. I have constructed the following test code which may explain better:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//
function whatFile() {
window.location= 'file:///' + document.form2.cmuds.value
}
// End -->
</script>
</head>
<body>
<div align="center">
</div>
<form name=form1>
<p align="center">
<input border="0" src="../"
name="image1" width="200" height="150" type="image"></p>
</form>
<p> </p>
<p> </p>
<p> </p>
<form name=form2>
<p align="center">
<input type=file name="cmuds" size="30">
<input type=button onClick="whatFile()" value="Open File"> </p>
</form>
</body>
</html>
As you may see, this code opens a browse of the hard drive and allows the user to select an image file. The problem is that when you press the "Open File" button the image opens in another window. I need the image to open in a specified "form field" ..... in this case "form1;image1" Is this possible?
Thanks again for your help!!
indymj
I know it is possible as it is done when selecting images to use as avatars on forums etc. So you might have to look into doing it with PHP, but I'm sure it is possible with javascript.
ASKER
Thanks SirRoss ....... Any javascript experts out there that can help?
Thanks
indymj
Thanks
indymj
I suggest opening that question up in the JavaScript topic, you will get more answers, and its part of the EE guideliens to only ask one question per post.
https://www.experts-exchange.com/Web/Web_Languages/JavaScript/
Theres a link, just set that question up and close this one, you'll get many more replies.
https://www.experts-exchange.com/Web/Web_Languages/JavaScript/
Theres a link, just set that question up and close this one, you'll get many more replies.
Isn't this question going to have points awarded, as it was two questions and the first one was answered in here.
ASKER
modulo,
Yes, SirRoss probably does deserve points since he reponded several times to my original question and suggested a different topic area where my question was answered in full.
I'm sorry about any confusion or misunderstanding .... I'm new and don't know all of the proper protical yet.
indymj
Yes, SirRoss probably does deserve points since he reponded several times to my original question and suggested a different topic area where my question was answered in full.
I'm sorry about any confusion or misunderstanding .... I'm new and don't know all of the proper protical yet.
indymj