Welcome Guest, Not a member yet? Register   Sign In
Re-populating Input file after validation


I'm using CI validation with MY_form_helper.php.

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

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,

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.

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


Theme © iAndrew 2016 - Forum software by © MyBB