function handler_upload()
 {
     if (ig_uploader()->get('igu_uploading')) {
         if (!wp_verify_nonce(ig_uploader()->post('_wpnonce'), 'igu_uploading')) {
             return;
         }
         $model = '';
         $id = ig_uploader()->post('IG_Uploader_Model[id]', 0);
         if ($id != 0) {
             $model = IG_Uploader_Model::model()->find($id);
         }
         if (!is_object($model)) {
             $model = new IG_Uploader_Model();
         }
         $model->import(ig_uploader()->post('IG_Uploader_Model'));
         if (!is_admin()) {
             if (isset($_FILES['IG_Uploader_Model'])) {
                 $uploaded = $this->rearrange($_FILES['IG_Uploader_Model']);
                 if (!empty($uploaded['file']['name'])) {
                     $model->file_upload = $uploaded;
                 }
             }
         }
         if ($model->validate()) {
             $model->save();
             wp_send_json(array('status' => 'success', 'html' => $this->render_single_file($model, true), 'id' => $model->id));
         } else {
             wp_send_json(array('status' => 'fail', 'errors' => $model->get_errors()));
         }
         exit;
     }
 }