Welcome Guest, Not a member yet? Register   Sign In
PDF Wont upload, other types work great
#1

[eluser]code_has_been_ignited[/eluser]
Hello

If someone would kindly help me out. I have a simple image upload form that uploads images (jpeg,gif,png) just awesome.

When I try to upload .PDF's it doesnt work.

This is the code called when I submit my form with the selected .pdf.

Code:
function do_upload() {
  
  $config = array(
   'allowed_types' => 'pdf|jpg|jpeg|gif|png',
   'upload_path' => $this->gallery_path,
   'max_size' => 200000
  );
  
  $this->load->library('upload', $config);
  $this->upload->do_upload();

Then nothing. I tried to debug it but this is whats displayed:

Code:
Array ( [upload_data] => Array ( [file_name] => [file_type] => [file_path] => /var/www/assets/media/ [full_path] => /var/www/assets/media/ [raw_name] => [orig_name] => [client_name] => [file_ext] => [file_size] => [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => ) )

I cannot figure this out. I would be ever so grateful if someone can help me out.

Thanks!
#2

[eluser]usefulidiot[/eluser]
What is the size of the pdf you are trying to upload?

From the manual
max_size - "The maximum size (in kilobytes) that the file can be. Set to zero for no limit. Note: Most PHP installations have their own limit, as specified in the php.ini file. Usually 2 MB (or 2048 KB) by default."
#3

[eluser]code_has_been_ignited[/eluser]
The pdf is 2.02 MB i checked my php.ini and the settings where larger then this.
#4

[eluser]code_has_been_ignited[/eluser]
I will correct my self...

I changed the values but forgot to restart apache. Issue solved.. Thanks for the help bud!

Best Regards!
#5

[eluser]superfake123[/eluser]
you always wanna do something like this so you can see any errors

Code:
$config = array(
    'allowed_types' => 'pdf|jpg|jpeg|gif|png',
    'upload_path'   => $this->gallery_path,
    'max_size'      => 200000
);
  
$this->load->library('upload', $config);

if ($this->upload->do_upload('Filedata'))
{
    .....
}
else
{
    log_message('error', $this->upload->display_errors());
}




Theme © iAndrew 2016 - Forum software by © MyBB