You are here: Re: How to retain user input in a form file field ? « HTML « IT news, forums, messages
Re: How to retain user input in a form file field ?

Posted by Yohan N. Leder on 06/09/06 17:19

In article <1149869349.757773.277150@h76g2000cwa.googlegroups.com>,
dorward@gmail.com says...
> Yohan N. Leder wrote:
> > Hi. Considering a form containg some input text fields, some checkboxes
> > and an upload file field. After submission, when I'm back to the form,
> > all values are retained unless the file field one. Is there a tips to do
> > this field behavior be the same as the other ?
>
> You can't set it (for security reasons), but you have the file on the
> server already. Keep track of where it on the server (give it a
> randomly generated filename or something), then give the user the
> option to keep or delete the file they've already uploaded (or replace
> it, or whatever).
>
>

Understood, but my problem is not exactly to decide what to do with the
already uploaded file (i.e. delete-it or leave-it on server), but to do
that user keep the same file field content when he pushes browser's back
button.

In my concrete case, user submitted a form containing a file field, for
preview. This preview is just on browser, nothing is kept on server
disk. So, from this preview, user can submit for real or be back to edit
and change his input. Actuallu, he has to browse and select a new time
the file to upload, everytime he go back from preview, even if the field
he wants to change is not the file one.

How to workaround this file field behavior (understood it's for security
reason) ?

For example, I've read from url below that an hidden field conatining a
client path could send the file data as does a file field :

http://groups.google.fr/group/comp.lang.javascript/browse_thread/thread/
9baaeeaf7df7a128/f69066e14ee61200?lnk=st&q=%22file+field%22+value&rnum=
42&hl=fr#f69066e14ee61200

Is it true ? If yes, I could manage to do this on onsubmit event using
some javascript code : copy file field value to hidden field and a
visible text one (to do user be aware of the uploaded file), then
destroy the file field element. Thus, when user be back from preview,
hidden and visible text fields keep their values. Of course, it's just
an idea and there's certainly a lot of drawback (for example, what if
user want to browse again knowing file field has been destroyed).

Do you think about another work around ?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация