CodeIgniter Forums
File Upload Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: File Upload Error (/showthread.php?tid=23204)



File Upload Error - El Forum - 10-03-2009

[eluser]mooders[/eluser]
Hi,

I am trying to upload a file, but the upload code in my controller is failing and displaying the following error: 'Status codes must be numeric'. I have tracked the issue down to the upload code, so relevant extracts from the view and controller follow:

View:
Code:
<?php echo form_open_multipart('profile/add'); ?>
<div id="padded">
    <label class="mylabelstyle">Photo:&nbsp;<span id="littleText">250Kb max file size; max 1024 x 768</span><br />
    &lt;input type="file" name="photo" class="myinputstyle" /&gt;
</div>

Controller:
Code:
//get photo upload
$config['upload_path'] = '/img/userphotos/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '250';
$config['max_width'] = '1024';
$config['max_height'] = '768';
        
$this->load->library('upload', $config);
            
if (!$this->upload->do_upload()){
    show_error('error', $this->upload->display_errors());
} else {
    $data = array('photo_upload' => $this->upload->data());
    $photo_name = $data['photo_upload']['file_name'];
    $photo_name .= $userid;
}

It's the
Code:
!$this->upload->do_upload()
condition in the Controller that's triggering the error.

The upload folder has write permissions and the file to be uploaded conforms to the $config rules. The error message doesn't appear to give much of a clue as to what is wrong...

Anyone with any ideas, please?

Many thanks,

Neil


File Upload Error - El Forum - 10-03-2009

[eluser]joeizang[/eluser]
hey,

status codes are server centric from the little googling that I have done. but why don't you remove the show_error() function and just try echoing the $this->upload->display_errors() and see.

Just a thot?!