Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

preview of file before file upload

Posted on 2006-07-06
13
323 Views
Last Modified: 2012-08-14
hello experts ,
I would want to give users a preview of the File which they are going to upload in pop window before they submit the request .
The file could be a pdf ,doc,xls file ,
Is there anyway i can do it with java script if not please suggest the best to do it ,
application a j2ee

thank you
0
Comment
Question by:eldoz12
  • 5
  • 3
  • 2
  • +1
13 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 250 total points
ID: 17054780
As preview you can use a simple window.open.
Like this:

<input type="file" name="myFile" onChange="window.open(this.value,'_blank','height=200,width=400');">


0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17055159
You can't preview a client-side file in your page unless you use a signed applet/activex.
0
 

Author Comment

by:eldoz12
ID: 17058483
Can i do it without using java-script .....
plz advice
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 63

Expert Comment

by:Zvonko
ID: 17058613
Come on.
User selects a local file. Press a button and see in a new window what he has selected, right? And that all without script? OK, but then you have to wait for new browsers with the built in feature <doWhatImean>

0
 

Author Comment

by:eldoz12
ID: 17058674
The problem is the file being uploaded can be a pdf ,xls,doc file how can i show the preview for such file formates ...i think i need to send it back to the server and some how come up with a way to show the perview
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17058849
Being uploaded, preview and upload and view does not feet under one hat. And it has noting to do with this Topic Area. Perhaps it is better you ask for move of this question to your server side scripting language TA, like ASP, PHP, Perl or what you use.

0
 

Expert Comment

by:braddini1433
ID: 17063546
you might be able to pop up the local file window.open("local path")
0
 

Expert Comment

by:braddini1433
ID: 17063557
<html>
<head>
<title>Untitled Document</title>

</head>

<body>
<script language="javascript">
      function popupfile(obj)
            {
                  window.open(obj.value);
            
            
            }

</script>
<FORM>
      <INPUT type="file" onChange="popupfile(this)">
      

</FORM>


</body>
</html>
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17065146
braddini1433, tell me please the difference betwean your proposal and my first proposal one day before yours.

0
 

Expert Comment

by:braddini1433
ID: 17069481
Not much to tell the truth the only different is that i split out the window.open into a funtion.

I saw the topic and had code for this on a web site i did for someone a wile back . didnt even bother reading the comments my bad ,Im sorry if i posted in haste
kind of got post happy.


 
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17069483
No problem :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question