CodeIgniter Forums
Re-populating Input file after validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Re-populating Input file after validation (/thread-8388.html)



Re-populating Input file after validation - El Forum - 05-16-2008

[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,


Re-populating Input file after validation - El Forum - 05-16-2008

[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.


Re-populating Input file after validation - El Forum - 05-16-2008

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

Thanks