Link to home
Start Free TrialLog in
Avatar of rwhubbard996
rwhubbard996Flag for United States of America

asked on

html form upload file using browse

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?
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

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.
Avatar of Loganathan Natarajan
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,.,
>> 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
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.
Avatar of rwhubbard996

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

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
Thanks, that really clarifies the issue!