Welcome Guest, Not a member yet? Register   Sign In
Input = file validation on multipart form
#1

[eluser]Linderman[/eluser]
Hell o! Smile

So, the situation is like this:

View:
Code:
<?php echo form_open_multipart('admin/infopages/info'); ?>
    
    <label>Infopage Title:</label><br />
    &lt;input type="text" name="title" value="" /&gt;&lt;br />
    
    <label>Infopage Content:</label><br />
    &lt;textarea name="content"&gt;&lt;/textarea><br />
    
    <label>Infopage Image:</label><br />
    &lt;input type="file" name="thumbnail" value="" /&gt;&lt;br />
    
    <label>Meta Keywords:</label><br />    
    &lt;textarea name="meta_keywords"&gt;&lt;/textarea><br />
    
    <label>Meta Description:</label><br />
    &lt;textarea name="meta_description"&gt;&lt;/textarea><br />
    
    &lt;input type="submit" name="submit" value="Save" /&gt;


&lt;/form&gt;

i am using multipart form!

in controller i am trying to say that input type='file' name='thumbnail' is required
Controller:
Code:
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
        
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('thumbnail', 'Image', 'required');

f($this->form_validation->run() == FALSE){
    $data['errors'] = TRUE;
} else {
    $data['errors'] = FALSE;

        ... and here goes image uploading code (not important for this problem)...
}

The problem is when i CHOOSE image and click the submit button CI always says "The Image field is required." AND I AM SHURE ITS NOT EMPTY. Why is that?

When i use normal form NOT MULTIPART its ok , CI gives the message only when i really didnt choose a file to upload (normal). But when i use multipart form CI blows this message always no matter the field is empty or not ...

Please, Help guys!


Messages In This Thread
Input = file validation on multipart form - by El Forum - 04-24-2010, 08:56 AM
Input = file validation on multipart form - by El Forum - 04-24-2010, 12:10 PM
Input = file validation on multipart form - by El Forum - 04-25-2010, 02:55 PM
Input = file validation on multipart form - by El Forum - 04-25-2010, 08:16 PM
Input = file validation on multipart form - by El Forum - 04-26-2010, 12:25 AM
Input = file validation on multipart form - by El Forum - 04-29-2010, 11:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB