Welcome Guest, Not a member yet? Register   Sign In
file upload doesn't repopulate value
#1

[eluser]robsen[/eluser]
I have got a form and inside the form I do an Image_upload with the help of a Popup. So the Popup is doing the upload and that works fine! I just got the problem that I can't repopulate the description inside the popup when the upload failes.
I'm using CI form_validation and uploading class

Here the code:
Controller

Code:
class Neuereintrag extends Controller {

    function Neuereintrag()
    {
        parent::Controller();
        $this->load->helper(array('form','url'));
        $this->load->library('form_validation');
        $this->load->library('session');
        $this->load->model('backend/entry_model', 'entry', true);    
    }
    function index()
    {        
      .....
    }
    function upload_image()
    {
        $this->load->view('backend/image_upload', array('error' =>''));
    }
    function do_upload()
    {
        $config['upload_path'] = './media/images/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_width'] = '122';
        $config['max_height'] = '98';
        
        $this->load->library('upload', $config);
        
        $this->form_validation->set_rules('image_desc','Beschreibung','required');
        
        $this->form_validation->set_message('required', 'Feld %s muss ausgefüllt sein!');

        $this->form_validation->set_error_delimiters('<div class="error">','</div>');
        
        if((!$this->upload->do_upload()) || ($this->form_validation->run() == FALSE))
        {
            $error = array('error' => $this->upload->display_errors());
            $this->load->view('backend/image_upload', $error);
        }
        else
        {
            $data = array('upload_data' => $this->upload->data());
            $vars ['image_id'] = $image_id =$this->entry->insert_image();
            $this->entry->insert_image_description($image_id);
            $this->load->view('backend/image_success', $vars);
        }
    }

View:
Code:
&lt;?php
echo $error;
echo form_open_multipart('admin/neuereintrag/do_upload');
echo form_label('Vorschaubild (122x98):', 'preview');
$data = array(
        'type' => 'file',
        'name' => 'userfile',
        'size' => '20',
        'value' => set_value('userfile')
        );
echo form_input($data)."<br><br>";
echo form_error('image_desc');
echo form_label('Beschreibung:', 'image_desc');
$data = array(
        'name' => 'image_desc',
        'size' => '80',
        'maxlength' => '200',
        'value' => set_value('image_desc')
        );
echo form_input($data)."<br><br>";
$button = array(
            'name' => 'submit',
            'class' => 'button',
            'value' => 'hochladen',
            );  
echo form_submit($button);
echo form_close();
?&gt;

Can you give me a hind what I'm doing wrong? In my "normal" form I got no problems with the set_value() - it's just not working in the popup!
#2

[eluser]robsen[/eluser]
Nobody??
#3

[eluser]megabyte[/eluser]
File inputs never get repopulated. It would be too much of a security issue.
#4

[eluser]robsen[/eluser]
Ok, that right!

But I got in the form also a description field and this doesn´t repopulate either!
That I don`t understand?!




Theme © iAndrew 2016 - Forum software by © MyBB