Re: Redisplay file name on failed upload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Miles Thompson wrote:
> When a file upload fails, not because of a problem with the upload itself,
> is there anyway of assigning the value captured by
> 
>   <input name="upldFile" type="file">
> 
> when the form is redisplayed?
> 
> The failure may not be due to a problem with the file being uploaded, but
> because the user failed to complete a keywords field or some other bit of
> wanted information.
> 
> Is it possible to assign form[ upldFile ] = "C:\somepath\somefile"
> or
> form[ upldFile ] = $_FILES['userfile']['name']
> 
> The script which does the validation is the same one which contains the
> upload form. I suspect we're completely out of luck - apart from validating
> with JavaScript.

it's a security measure that you are not able to set the value of file upload element,
neither by filling the value attribute literally nor by using javascript.

this is because your page is not allowed access to the local filesystem ... if you
are able to do it then your looking at a browser bug.

what you can do is place the full local path the the file in question
above/below the file upload element to help the user.

a better alternative would be to temporarily store the file in the staging area
and redisplay the form without the upload element (and inform the user the file is
already on the server) and have the user fill everything else correctly
- once you recieve the rest of the data correctly you can pluck the
relevant file from the staging area.

another tactic would be to use a multi-page form and have the upload on the last
page, only showing the last page when everything else has been submitted correctly.

> 
> Regards - Miles
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux