El Forum
08-08-2012, 06:43 AM
[eluser]malzahar[/eluser]
I'm having trouble getting file uploads to work with my form. I made sure the upload folder permissions are correct (755) and the library looks to be configured properly but when I try to do an upload it just fails but does not return any errors. If anyone could take a look at this for me it would be much appreciated.
Parts of the form that matters.
Part of the controller that matters
I'm having trouble getting file uploads to work with my form. I made sure the upload folder permissions are correct (755) and the library looks to be configured properly but when I try to do an upload it just fails but does not return any errors. If anyone could take a look at this for me it would be much appreciated.
Parts of the form that matters.
Code:
echo form_open_multipart('form/form_validate', $attributes);
echo form_upload('userfile');
echo form_submit('submit', 'Submit');
echo form_close();
Part of the controller that matters
Code:
function form_validate() {
//some validation rules none that apply to the file upload
if($this->form_validation->run() == TRUE) {
$config = array(
'allowed_types' => 'jpg|jpeg|pdf',
'upload_path' => realpath(APPPATH . '../uploads/'),
'max_size' => 1500,
);
$this->load->library('upload', $config);
if(!$this->upload->do_upload('userfile')) {
echo "failed to upload";
echo $this->upload->display_errors('<p>', '</p>');
}
else {
echo "file uploaded";
}
}