Welcome Guest, Not a member yet? Register   Sign In
Upload Library - No error, but no file uploaded and no data returned
#1

[eluser]Unknown[/eluser]
I am having trouble with the CI upload library. My issue:

I have a form to create a new database entry creating data for categories. I have named the upload field everything from userfile (default) to "terrorists" and passed the value to do_upload() if it wasn't userfile. All other data is entered into the database appropriately, and no error message is displayed by the uploader, but the file is not uploaded, and $this->upload->data() returns nothing of value. I have tried forcing it to break by uploading an executable (should require image), and that won't even throw an error.

Things I have tried:
- Name the field differently (including "userfile")
- Check CHMOD on upload directory
- Uploading a file which does not fit allowed file types
- Uploading before or after validation (I know, why upload before ensuring valid data...)
- Checking view output (valid form, multipart, etc.)
- Checking consistency of other data submitted with form

Does anyone have any suggestions?

Note: I am using the form helper functions and passing the field information to the view to build the form.
#2

[eluser]ontguy[/eluser]
I'll paste a sample of code I've used that works.

with the upload form field called userfile

the upload portion of the controller
Code:
$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '100';
$config['max_width']  = '1024';
$config['max_height']  = '768';
$config['overwrite']  = TRUE;
$config['encrypt_name']  = TRUE;
$this->load->library('upload');
$this->upload->initialize($config);

if (!$this->upload->do_upload())
{
  echo 'Upload failed';
}

print_r($this->upload->data());
#3

[eluser]Unknown[/eluser]
As soon as I read that, I realized my mistake. I had the config in another array and passed the containing array rather than the actual config. I'm surprised I didn't catch that.




Theme © iAndrew 2016 - Forum software by © MyBB