Solved

html form upload file using browse

Posted on 2008-06-17
8
215 Views
Last Modified: 2011-09-20
I have a long form that allows a user to upload an image.

There is a lot of validation required and if a users input does not validate an error message is printed and the form is refreshed with all the input entered so far.

So far so good.

the input in the upload image 'browse' is lost when the form is refreshed.

Where can I find this info so I can reprint what was previously entered?
0
Comment
Question by:rwhubbard996
[X]
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
  • 4
  • 2
  • 2
8 Comments
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 21809197
You have no access to that information in any modern browser, sorry.  If you could access that directly you could upload ANY file from the user's computer without their permission.
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21811389
Yes, it is too complex to do that on this condition. better try to use AJAX to avoid the page refresh OR when you submit try to upload the files and display them near the control it is uploaded ... facility to remove / confirm to upload ... something like,.,
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21811392
>> Where can I find this info so I can reprint what was previously entered?

you cannot reprint to the control ., but you can get the value / name selected the files and display them
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:rdivilbiss
ID: 21813713
Or do an initial validation in JavaScript before your server side checks.

Also watch out for echoing user input back to the fields...open your form for XSS.
0
 

Author Comment

by:rwhubbard996
ID: 21814758
I was trying to be so clear with my question, sorry not sure I was.

I haven't used the 'browse'  function before and feeling the pressure of a deadline posted the question hoping for a simple solution.

Now at the start of the day and after reading the comments I started thinking (always good for a developer to think :-) ).

The 'browse' is a javascript function? I'm, thinking it must be a client side script of some sort to see the users files.  The information that gets printed in the window, the file name and path, is partially visible in the $_FILE array.  I can access the file name but not the path.

Right now I'm not in a position to dissect the inner workings of this function.  

My guess is if I can grab the path and file name I can put it back in the text field of the form so the user doesn't  have to enter it again.

After reading the comments I'm doubting my 'guess'.  The client server divide may prevent what seemed simple at first glance.

Any further clarification would be appreciated.

Thanks
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 500 total points
ID: 21815551
If you look at the data from a for upload (say using Live HTTP Headers for FF) you'll see the name-value pairs passed in clear text followed by a form multipart line, then the BASE64 encoded contents of the file the user chose to upload via your form.

You'll get the filename as well.

From the aspect of manipulating what is displayed on the user's browser, you can use script to manipulate nearly every aspect of the page "EXCEPT" a file control.  It isn't that you cant see the filename once it is uploaded, but you have no way of filling a file field with any data, even if your purpose is simply to redisplay what the user already chose.

That is the protocol for the file field as specified by the W3C and is how all browsers implemented the field.
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 21815606
0
 

Author Closing Comment

by:rwhubbard996
ID: 31468170
Thanks, that really clarifies the issue!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
easy to understand video about affiliated marketing for a beginner 3 66
Sending an input value from a view to a controller in MVC 3 44
asp Google Map 2 89
original content 7 116
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to dynamically set the form action using jQuery.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

739 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