...

View Full Version : thumbnail in Windows "Open file" dialogue



luzmedia
12-31-2003, 09:30 PM
I am coding an ASP page to upload image files to the server using an HTML form with <input type="file"... which is then passed to ASPUpload.

Is there any way of making the Windows "Open file" window that comes up in response to type="file" show a thumbnail to show what any file clicked on looks like before it's selected?

Cheers
Charlie

A1ien51
12-31-2003, 09:36 PM
you are most likely stuck with what you got there.

glenngv
01-05-2004, 10:20 AM
try this:


<html>
<head>
<script type="text/javascript">
var isImage=false;
function getFileInfo(oFile,e){
//IE triggers both onclick and onchange while NS/Moz triggers onclick only
if (oFile.value=='' || (document.all && e.type=='click')) return;
var file = new Image();
file.onerror = function(){
alert('Attached file is not an image.');
isImage=false;
}
file.onload = function(){
isImage=true;
}
file.src = 'file:///' + oFile.value.replace(/\\/g,'/');
document.images['preview'].src=file.src;
}

function check(){
if (!isImage) alert('Please attach an image file.');
return isImage;
}
</script>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="PUPload.asp" onsubmit="return check()">
<input type="file" name="file1" onclick="getFileInfo(this,event)" onchange="getFileInfo(this,event)">
<input type="submit">
<p>Preview:<br>
<img name="preview" src="transparentPic.jpg">
</p>
</form>
</body>
</html>

luzmedia
01-07-2004, 09:07 PM
Fantastic - thanks, Glenn - works a treat!
Charlie

Morgoth
01-07-2004, 11:01 PM
Wow, that's amazing...
I might..
Have to...
use this..
hehe.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum