Welcome Guest, Not a member yet? Register   Sign In
file upload returns size -2
#1

[eluser]EyeAmN8[/eluser]
I've been working on getting multiple file upload working and ran into a problem. I was getting errors from the upload library line 608 saying getimagesize failed, so I did a print_r on the file being uploaded and it return error => 0 and size => -2 ??? I haven't seen negative 2 before, so kinda lost.

Here's my view
Code:
<form class="form-horizontal" acti site_url('controller/function/param') ?> method="post" enctype="multipart/form-data">
<input type="file" id="userfile" name="userfile" size="20"/>

Then the controller goes straight to the model to do the work. This is just part of the model that does the upload. If this part works then the rest will work. I had it working before I tried to upload multiple files, then after I reverted back to single it stopped working ??
Code:
public function user_single_upload($action)
{
  if($action == 'save')
  {
   //check file type to get path and type
   $file = $_FILES['userfile']['name'];
   $ext = substr(strrchr($file, '.'), 1);

   if(($ext == 'jpg') || ($ext == 'jpeg') || ($ext == 'png') || ($ext == 'gif'))
   {
    $type = "Image";
    $path = "images/";
   }
   elseif(($ext == 'pdf') || ($ext == 'doc') || ($ext == 'txt')|| ($ext == 'rtf'))
   {
    $type = "Document";
    $path = "documents/";
   }
   elseif(($ext == 'mp3') || ($ext == 'wav'))
   {
    $type = "Audio";
    $path = "audio/";
   }
   elseif($ext == 'avi')
   {
    $type = "Video";
    $path = "videos/";
   }
   else
   {
    $type = "Other";
    $path = "other/";
   }

   // upload part
   $config['upload_path'] = './uploads/'.$path;
   $config['allowed_types'] = 'gif|jpg|png|jpeg|txt|doc|pdf|rtf|mp3|wav|avi';
   $config['max_size'] = '1000';
   $config['max_width']  = '1000';
   $config['max_height']  = '1000';
   $config['remove_spaces'] = TRUE;

   $this->load->library('upload');
   $this->upload->initialize($config);

   if ( ! $this->upload->do_upload())
   {
    //$error = array('error' => $this->upload->display_errors());
    $fsize = print_r($_FILES['userfile']);
    $info['err'] = "there was an error<br /> path - ".$path."<br />ext - ".$ext."<br />file - ".$file."<br /> print_r - ".$fsize;
    $info['success'] = "";
    $info['msg'] = "";
   }




Theme © iAndrew 2016 - Forum software by © MyBB