0

Hi there ,
How to retain value file upload input in codeigniter?
Please give me an idea?

i am using below one: but not working..

<input type="file" name="image1" value="<?php echo set_value('image1')?>" class="form-control" style="width:300px;" id="dealImg">

Edited by praba_web: update

4
Contributors
5
Replies
33
Views
2 Years
Discussion Span
Last Post by praba_web
0

@philjen

Hi, OP asks if he can use set_value() to return the uploaded file path when going back to the form due, for example, to the validation process.

The function set_value() will not work with an input file type tag because of the HTML specification and because browsers do not allow to preset a value for this type of input field.

In practice:

<input type="file" name="image1" value="/path/to/file.jpg" />

does not work. The value attribute is not accepted.

Alternative: when the form is submitted, if the validation does not fail because of the file but due to another input field, he can save the file and when going back to the form, show the file a part. Like an attachment, with the option to replace it.

Also note that Ellislab does not support anymore CodeIgniter, from now on you should refer to:

1

I believe that this post is live only because the author didn't marked it as solved , he made a second post in this sequence with another approach , so it isn't really an active thread.

@philjen it is great that you want to help others and I hope you continue doing so here , but take a moment to read their questions.

Is there a way to emulate repopulate of the contents of a file input in modern browsers ? .. Yes , but this is far too complicated for the question. If this is what the author tried to do , and had no alternatives there are ways (it is more a JS matter than PHP) , but the question has many simple solutions that just need an effort to understand how web works in its elementary levels.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.