• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upload Error 1?

#1
[eluser]Matalina[/eluser]
Not so much asking for help. But when I'm moving working code to another location with some tweaks and refactoring for a Intranet system where all apps are one unit instead of the 3 or 4 I have now as working models. It's no longer working. But I'm sure I can fix that.

My question is what the error 1 mean when I upload. Nothing else is displayed, just a 1.

My error message output:
Quote:Images caused a failure to creating a new promotion
1
My error output code:
Code:
$this->session->set_flashdata('error','<div class="alert-box error">Images caused a failure to creating a new promotion<br/>'.print_r($this->upload->display_errors()).'</div>');

I've gotten it before and it's been permission issues, I think but it's been a while since I did this part of the code so the exact fix is not in my memory. I"ll post it once I fix it but I'm curious why 1 and why no translations and wonder if we might be able to get a better message for an error.

#2
[eluser]Matalina[/eluser]
echoing the error before doing my check gave me a human readable message. just bizarre.

You are not allowed to upload this file type.

However my file types were set to jpg|jpeg|gif|png and I was uploading a jpg.

I changed the allowed types to * and now it's working. Great - not!

fun fun.

#3
[eluser]Matalina[/eluser]
What am I missing?

IMGS_PATH is set to the right path with a trailing slash

uploading a 344KB jpg file.

error message:
Quote:The filetype you are attempting to upload is not allowed.

Code:
// Upload images & resize
        $this->load->model('Image_model');
  
        // Set  up Upload Library configuration
        $config['upload_path'] = IMGS_PATH.'promotions/full';
        $config['allowed_types'] = 'gif|jpg|jpeg|png';
        $config['max_size']    = '10240'; //10M
        $config['encrypt_name'] = TRUE;
  
        $this->load->library('upload');
  
        $image_files = array();
  
        if(!empty($_FILES['image_1']['name'])) { // If there are images
          $image_files = array();
          foreach($_FILES as $key => $value) { // for all images uploaded
            if( ! empty($key['name'])) {
              $this->upload->initialize($config); // Initialize Upload library
              $check = $this->upload->do_upload($key);
              $errors = $this->upload->display_errors();
              if (!$check) { // If image did not load return errors
                $this->session->set_flashdata('error', '<div class="alert-box error">Images caused a failure to creating a new promotion<br/>'.$errors.'</div>');
                redirect('promotions/create');
              }
              else { // If image uploaded
                $data = $this->upload->data();
  
                $image_files[] = $data['file_name'];
  
                $this->Image_model->resize_flyers($data['file_name']); // resize the image
              }
            }
          }
        }

#4
[eluser]Matalina[/eluser]
Not the optimal way but I got it working.

allowed_types = * and check the file extension before do_upload.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.