How to get the file's name after click the Browse... in HtmlInputFile

K

Kylin

click the Browse... button,
and choose a image from local disk,OK.
and how to show the image in the webpage .
before it be uploaded ?
 
M

Munsifali Rashid

Add an image to your page, and change it's src property to the value in the
file input box.

Eg.

<img name="preview" src="blank.gif">
<input name="newImage" type="file">
<input type="button" onClick="previewImage()">

<script language="javascript">
<!--
function previewImage()
{
var filename = document.forms[0].elements["newImage"].value;
var img = document.all.preview;
img.src = filename;
}
//-->
</script>

This code hasn't been tested, and might need some modification, but it
should give you an idea of what you need to do.

Mun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top