⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Upload Error



VollS

VollS
  • profile picture
  • Member

Posted 27 April 2016 - 15:20 PM

Hi,

 

I am new to this forum, building a inhous app with Grocery Crud 1.5.4 and Codeigniter 3.0.6.  I have a partner management within my app where i should upload an image, but it always results in an Box saying "Upload Error" only and {success:false} in firebug console. Have to say, that checking file type works, also checking writeable of upload path works. if i deny access, the right error is coming up.

 

I see jquery-1.11.2.min.js line 4 in firebug console, reply {success:false}

 

The post has the data of the image attached. In background under the "Upload Error Box" I see "File uploading" "Progress 100%" ( I see it in german so translation may vary :-) )

Is there any way to debug this? Running FreeBSD 10/64Bit with Apache 2.4 and PHP 5.6.19 on https:// only. But opening http has the same result.

 

The code (all included callbacks works without a problem) needed some extra alpha checks because php doesnt check ÖÄÜöäüß - german umlauts and numeric here has a decimal , instead of the . .

logo field is varchar(255)

looking for hours, found no way to debug this right........ thank you!
 

############

 

       public function mgmt_partner()
        {
           $group = array('admin', 'partnerview');
            
            if (!$this->ion_auth->logged_in() || !$this->ion_auth->in_group($group))
            {
                // redirect them to the login page
                redirect('ctserp/login', 'refresh');
            }

            $crud = new Cts01_Grocery_CRUD(); // yes there is a numeric addition in it, works fine
            
            $crud->set_table('ctserp_partner');
            $crud->set_relation('country_code','ctserp_countries','country_name');
            
            $crud->columns('firma', 'city', 'country_code', 'email', 'telefon', 'uidchecked');
            $crud->unset_add_fields('created', 'REpersonId','uidchecked', 'uidcheckresponse','logo'); // REpersonid can only be available on edit if persons exists
            $crud->unset_edit_fields('created');
            
            $state = $crud->getState();
            if($state == 'read' || $state == 'edit')    
            {   
                $akt_key = $crud->getStateInfo()->primary_key;
                $crud->set_relation('REpersonId','ctserp_personen', '{nachname} {vorname}, {email}',
                                     'personenId IN (select personenId from ctserp_personen where firmenId =' . $akt_key . ' and gesperrt ="0")');
            }
            if($state == 'edit')
            {
                    $crud->field_type('uidchecked', 'readonly');
                    $crud->field_type('uidcheckresponse', 'readonly');
            }

            $crud->set_subject(lang('mgmt_partner'));

            $crud->add_action(lang('mgmt_personen'), '', '', 'fa fa-male', array($this,'mgmt_partner_personen_sub')); // create link with sub of below
                
            $group = array('admin', 'partneredit');
            if ($this->ion_auth->logged_in() &&  $this->ion_auth->in_group($group))
            {
                $crud->add_action(lang('mgmt_uidcheck'), '', '', 'fa fa-check', array($this,'mgmt_partner_uidcheck_sub'));
            }

            $crud->field_type('updated', 'hidden', date("Y-m-d H:i:s") );
        
            $crud->display_as('firma', lang('firma'));
            $crud->display_as('firma2', lang('firma2'));
            $crud->display_as('addressLine1', lang('addressLine1'));
            $crud->display_as('addressLine2', lang('addressLine2'));
            $crud->display_as('postalCode', lang('postalCode'));
            $crud->display_as('city', lang('city'));
            $crud->display_as('state', lang('state'));
            $crud->display_as('country_code', lang('country_name')); // we show header for name which is relation!
            $crud->display_as('telefon', lang('telefon'));
            $crud->display_as('mobiltelefon', lang('mobiltelefon'));

            $crud->display_as('email', lang('email'));
            $crud->display_as('emailnewsletter', lang('emailnewsletter'));
            $crud->display_as('homepage', lang('homepage'));
            $crud->display_as('kunde', lang('kunde'));
            $crud->display_as('REpersonId', lang('REpersonId'));
            $crud->display_as('deb_time_rate', lang('deb_time_rate2'));
            $crud->display_as('lieferant', lang('lieferant'));
            $crud->display_as('cred_payout_default', lang('cred_payout_default'));
            $crud->display_as('partner', lang('partner'));
            $crud->display_as('uidnummer', lang('uidnummer'));
            $crud->display_as('uidchecked', lang('uidchecked'));
            $crud->display_as('uidcheckresponse', lang('uidcheckresponse'));
            $crud->display_as('firmenbuch', lang('firmenbuch'));
            $crud->display_as('bankname', lang('bankname'));
            $crud->display_as('bankbic', lang('bankbic'));
            $crud->display_as('bankiban', lang('bankiban'));
            $crud->display_as('paypal', lang('paypal'));
            $crud->display_as('bitcoins', lang('bitcoins'));
            $crud->display_as('notiz', lang('notiz'));
            $crud->display_as('logo', lang('logo'));
            $crud->display_as('created', lang('created'));
            $crud->display_as('updated', lang('updated'));

            $crud->required_fields('firma', 'country_code', 'email');
            $crud->set_rules('firma', lang('firma'), 'required|callback_alnumspaces|min_length[2]|max_length[50]');
            $crud->set_rules('firma2', lang('firma2'), 'callback_alnumspaces|min_length[2]|max_length[50]');
            $crud->set_rules('addressLine1', lang('addressLine1'), 'required|min_length[5]|max_length[50]');
            $crud->set_rules('addressLine2', lang('addressLine2'), 'max_length[50]');
            $crud->set_rules('postalCode', lang('postalCode'), 'required|callback_alnumspaces|min_length[3]|max_length[8]');
            $crud->set_rules('city', lang('city'), 'required|callback_alnumspaces|min_length[3]|max_length[50]');
            $crud->set_rules('state', lang('state'), 'callback_alnumspaces|min_length[3]|max_length[50]');
            $crud->set_rules('telefon', lang('telefon'), 'callback_alnumspaces|min_length[3]|max_length[50]');
            $crud->set_rules('mobiltelefon', lang('mobiltelefon'), 'callback_alnumspaces|min_length[3]|max_length[50]');
            $crud->set_rules('email', lang('email'), 'required|valid_email|min_length[3]|max_length[50]');
            $crud->set_rules('homepage', lang('homepage'), 'valid_url|min_length[3]|max_length[50]');
            $crud->set_rules('deb_time_rate', lang('deb_time_rate'), 'callback_numericdecimalornone');
            $crud->set_rules('uidnummer', lang('uidnummer'), 'callback_alnum|min_length[8]|max_length[25]');
            $crud->set_rules('bankname', lang('bankname'), 'callback_alnumspaces|min_length[3]|max_length[50]');
            $crud->set_rules('bankbic', lang('bankbic'), 'callback_alnumspaces|min_length[3]|max_length[11]');
            $crud->set_rules('bankiban', lang('bankiban'), 'callback_alnumspaces|min_length[3]|max_length[34]');
            $crud->set_rules('paypal', lang('paypal'), 'valid_email|min_length[3]|max_length[50]');
            $crud->set_rules('bitcoins', lang('bitcoins'), 'callback_alnum|min_length[3]|max_length[255]');
            $crud->set_rules('notiz', lang('notiz'), 'callback_alnumspaces|min_length[3]|max_length[100]');

            $crud->setNumericFields($this->config->item('decimal_point'), 'deb_time_rate');  // multi fields sep with , '' , ''.....

            // LOGO UPLOAD only on edit because no partner ID for FILESTORE PATH on add:

            $group = array('admin', 'partneredit');
            if ($this->ion_auth->logged_in() && $this->ion_auth->in_group($group))
            {
                if($state == 'edit')

 

                   $this->config->set_item('grocery_crud_file_upload_allow_file_types','gif|jpeg|jpg|png');

                    $fpath = $this->_get_filestore_path('FILESTORE', 'LO'.$this->grocery_crud->getStateInfo()->primary_key);
                    $crud->set_field_upload('logo', $fpath);    // we store in FILESTORE/L/O/IDchar2/IDchar2/......
                }
            }


            // callbacks:
            // set http:// if they forget it

            $crud->callback_before_insert(function($post_array){
                if ($post_array['homepage'] && !preg_match('/^http/i',$post_array['homepage']))
                {
                        $post_array['homepage'] = "http://" .  $post_array['homepage'];
                }
                return $post_array;
            });

            $crud->callback_before_update(function($post_array){
                if ($post_array['homepage'] && !preg_match('/^http/i',$post_array['homepage']))
                {
                        $post_array['homepage'] = "http://" .  $post_array['homepage'];
                        $post_array['updated'] = date("Y-m-d H:i:s");
                }
                return $post_array;
            });

            // if view only unset operations:
            $group = array('admin', 'partneredit');
            if (!$this->ion_auth->logged_in() || !$this->ion_auth->in_group($group))
            {
                $crud->unset_add();
                $crud->unset_edit();
                $crud->unset_delete();
            }
            
            // show page
            $output = $crud->render();
            $this->_main_output($output);

        }

 

 

       // this gets our upload path
       // no base means default FILESTORE. if base send full URL.
        public function _get_filestore_path($base='', $ref)
        {
            
            if (! $base) {
                $base=FCPATH."FILESTORE"; //  PAthes are defined in index.php of codeigniter
                // http://stackoverflow.com/questions/13992074/codeigniter-path-functions-definitions
            }
        
            $ref=substr($ref, 0, 5); // trim ref to max 8 chars

            $folder="";
            for ($n=0;$n<strlen($ref);$n++)
            {
                $folder.=substr($ref,$n,1);
                $folder.="/";
                if ((!(file_exists($base . "/" . $folder)))) {mkdir($base . "/" . $folder,0777);chmod($base . "/" . $folder,0777);}
            }
            
            return $base . "/" . $folder;
        }

 

 


VollS

VollS
  • profile picture
  • Member

Posted 04 May 2016 - 16:17 PM

The Error occurs at Line 115 of : jquery.fileupload.config.js

I am no JS Expert, so its hard for me to continue searching for the problem.

 

71             done: function (e, data) {
     72                 if(typeof data.result.success != 'undefined' && data.result.success)
     73                 {
     74                     $("#loading-"+unique_id).hide();
     75                     $("#progress-"+unique_id).html('');
     76                     $.each(data.result.files, function (index, file) {
     77                         $('#upload-state-message-'+unique_id).html('');
     78                         $("input[rel="+uploader_element.attr('name')+"]").val(file.name);
     79                         var file_name = file.name;
     80
     81                         var is_image = (file_name.substr(-4) == '.jpg'
     82                                             || file_name.substr(-4) == '.png'
     83                                             || file_name.substr(-5) == '.jpeg'
     84                                             || file_name.substr(-4) == '.gif'
     85                                             || file_name.substr(-5) == '.tiff')
     86                             ? true : false;
     87                         if(is_image)
     88                         {
     89                             $('#file_'+unique_id).addClass('image-thumbnail');
     90                             load_fancybox($('#file_'+unique_id));
     91                             $('#file_'+unique_id).html('<img src="'+file.url+'" height="50" />');
     92                         }
     93                         else
     94                         {
     95                             $('#file_'+unique_id).removeClass('image-thumbnail');
     96                             $('#file_'+unique_id).unbind("click");
     97                             $('#file_'+unique_id).html(file_name);
     98                         }
     99                         
    100                         $('#file_'+unique_id).attr('href',file.url);
    101                         $('#hidden_'+unique_id).val(file_name);
    102
    103                         $('#success_'+unique_id).fadeIn('slow');
    104                         $('#delete_url_'+unique_id).attr('rel',file_name);
    105                         $('#upload-button-'+unique_id).slideUp('fast');
    106                     });
    107                 }
    108                 else if(typeof data.result.message != 'undefined')
    109                 {  
    110                     alert(data.result.message);
    111                     show_upload_button(unique_id, uploader_element);
    112                 }  
    113                 else
    114                 {
    115                     // KMJ Error is here
    116                     alert(error_on_uploading);
    117                     show_upload_button(unique_id, uploader_element);