Link to home
Start Free TrialLog in
Avatar of MoMarvi
MoMarvi

asked on

Preview file before upload

I want to have a user upload a file from a web page. I know about the file upload process, but is there a way to have the user preview the file (In this case a jpeg, or bmp) before the upload?

This will prevent accident uploads of the wrong information. Due to the size of the files, and dial-up connection, a preview possibility would be the best.
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

The first problem you have is the fact that FileSystemObject does not run on the client... if it did, there would be a lot of happy people.

However, knowing that you can pass the name of the file selected with a browse button;

<INPUT TYPE=FILE SIZE=25 NAME="FileData">

You should be able to pass this value to a script that will open a new viewing window.

<form action=upload.asp>
<INPUT TYPE=FILE SIZE=25 NAME="FileData">
<input type="submit" name=View value="View..." onClick="poplist(this.form)">

<% If action="view" Then
Request.Form(view)
%>
function poplist(<%=Request.Form(view)=%>){          
       winwidth = 500;
       winheight = 400;  
       winleft   = 50;
       wintop    = 50;

var myoption=form.view.selectedIndex
var theFile = form.view.options[myoption].value;
           
window.open(theFile, 'test','top=' + wintop + ',left=' + winleft + 'screenX=' + wintop + ',screenY=' + winleft + ',height=' + winheight + ',width=' + winwidth);    
  }    
....

(untested...)
Avatar of MoMarvi
MoMarvi

ASKER

Sounds good,

I also came across the file upload control in the micro$oft web publishing sdk. I'll try your script first though since it doesn't need an ActiveEchs download.
Hang on a minute... this won't process a file upload, you still need an external component to process the upload.  Check out www.dougdean.com for an upload component.

Mark
Avatar of MoMarvi

ASKER

I understand it won't process the upload, I want to be able to view the file before it is uploaded.

I think the script needs some work, I'll come back with what happens.
It does need some work... I wish I had more time for this, it's a good idea.  I did notice one error immediatly;

<input type="submit" name=View value="View" onSubmit="poplist(this.form)">
ASKER CERTIFIED SOLUTION
Avatar of Flubbadub
Flubbadub

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MoMarvi

ASKER

This is exactly what I need. Sorry mgfranz, but Flubbadub's answer worked straight out of the box.
Cool, I was able to get the snippet I posted working last night, I like Flubb's code, easily configurable and all VBS.