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.
LVL 2
MoMarviAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mgfranzCommented:
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...)
0
MoMarviAuthor Commented:
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.
0
mgfranzCommented:
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
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

MoMarviAuthor Commented:
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.
0
mgfranzCommented:
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)">
0
FlubbadubCommented:
Try opening the value of the file upload box in a new window for example:

<HTML>
<BODY>

<SCRIPT LANGUAGE=VBScript>
Sub BtnPreview_onclick
select case cstr(right(document.FrmUpload.flUpload.value,4))
      case ".jpg",".gif","jpeg",".htm","html"
            window.open document.FrmUpload.flUpload.value,"winPreview"
      case else
            msgbox "Files of that type cannot be previewed!"
end select
End Sub

</SCRIPT>

<FORM NAME=FrmUpload ACTION=xxx METHOD=xxx>
<INPUT TYPE=File NAME=flUpload ID=flUpload></INPUT>
<INPUT TYPE=BUTTON NAME=BtnPreview ID=BtnPreview VALUE="Preview"></INPUT>
</FORM>
</BODY>
</HTML>

This means that the post action of your form does not need to change!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MoMarviAuthor Commented:
This is exactly what I need. Sorry mgfranz, but Flubbadub's answer worked straight out of the box.
0
mgfranzCommented:
Cool, I was able to get the snippet I posted working last night, I like Flubb's code, easily configurable and all VBS.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.