2

I have a form where user fills up (jsp page). One of the input is of type "file". There is a preview button which will pop up a new window and using javascript to layout the filled up form for display. The "file" input will be display as a hyperlink and when the user clicked on the hyperlink, it is supposed to open the attachment. So if you attached pdf, I would expect that when I clicked on the hyperlink, foxit reader will open. if it is a text file, notepad will open.

I tried using file:// but nothing seems to happened. it seems to be a security feature in MSIE where file:// protocol is locked down.

How do you go about implementing this feature without(ActiveX, ajax)?

Kara
6,23616 gold badges54 silver badges58 bronze badges
asked May 24, 2009 at 4:37

1 Answer 1

3

file:// only points to the local file system on the user's computer, and is often subject to more locked down security measures. It simply can't be relied upon the the browser will even allow file:// protocol access.

The only way to safely do what you want is to fully submit the form with the file and use a server side language (PHP, ASP.NET, Rails, Django, take your pick) to render out a page with the 'pretty' layout of the form data as well as a preview of the document. This is how forums do it, you hit the "preview" button and your post is submitted to the server, the server renders it for your approval, you approve it, and it gets saved to the database and published. If you don't approve it, it gets discarded and never makes it to the database.

If you don't want the user to leave the page, you can roll this into your validation and do an AJAX postback. There are javascript libraries specifically for serializing and transmitting forms silently like this, and then returning the results. JQuery Forms is a good example of this (note: requires JQuery).

answered May 24, 2009 at 4:52
Sign up to request clarification or add additional context in comments.

1 Comment

I think he means before the user uploads there file. Like to check its the right file. So if they say enter that they want to upload "C:/MyTextdocument.txt" per se, He wants to go open "file://c:/MyTextdocument.txt" which I would expect to work? Because the user has specified the local path to the file.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.