• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Re-populating Input file after validation

#1
[eluser]Salim[/eluser]
Hi,

I'm using CI validation with MY_form_helper.php.

In my form, I have an
Code:
input type="file"
.
To generate it, I have modified the helper MY_form_helper, adding this function to generate the input file.

Code:
function form_input_file($data = '', $value = '', $extra = '')
{
    $name = ( ! is_array($data))?$data:((isset($data['name']))?$data['name']:'');
    $value = (isset($_POST[$name]))?$_POST[$name]:((isset($_GET[$name]))?$_GET[$name]:$value);
    $defaults = array('type' => 'file', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value, 'maxlength' => '500', 'size' => '50');

    return "<input ".parse_form_attributes($data, $defaults).$extra." />\n";
}

I just have modified the 'type' => 'file'...

Unfortunately, after validation, the value of the input file is not saved ...

Does anyone have a solution ??

Thanks in advance,

#2
[eluser]xwero[/eluser]
There is no solution. It is a security measure in the browsers that prevents the selection of a file. Lets say a rogue site loads a file with paswords from your machine in a hidden file input because the browser has permission to browse your drive(s). You don't want that to happen.

#3
[eluser]Salim[/eluser]
Ok xwero ... I'm sad to read that ... but you are right: in term of security, I fully understand it ...

Thanks


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.