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

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
My error output 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.

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.

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.

// Upload images & resize
        // 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;
        $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>');
              else { // If image uploaded
                $data = $this->upload->data();
                $image_files[] = $data['file_name'];
                $this->Image_model->resize_flyers($data['file_name']); // resize the image

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.