public function delete_file($state_info)
 {
     if (isset($state_info->field_name) && isset($this->upload_fields[$state_info->field_name])) {
         $upload_info = $this->upload_fields[$state_info->field_name];
         if (file_exists("{$upload_info->upload_path}/{$state_info->file_name}")) {
             if (unlink("{$upload_info->upload_path}/{$state_info->file_name}")) {
                 $this->basic_model->db_file_delete($state_info->field_name, $state_info->file_name);
                 return true;
             } else {
                 return false;
             }
         } else {
             $this->basic_model->db_file_delete($state_info->field_name, $state_info->file_name);
             $ci =& get_instance();
             $last_deleted_files = $ci->session->userdata('gc_last_deleted_files');
             if (!is_array($last_deleted_files)) {
                 $last_deleted_files = array();
             }
             if (!in_array($state_info->file_name, $last_deleted_files)) {
                 $last_deleted_files[] = $state_info->file_name;
                 $ci->session->set_userdata('gc_last_deleted_files', $last_deleted_files);
             }
             return true;
         }
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: Grocery_CRUD.php プロジェクト: qwords/evote
 protected function delete_file($state_info)
 {
     if (isset($state_info->field_name) && isset($this->upload_fields[$state_info->field_name])) {
         $upload_info = $this->upload_fields[$state_info->field_name];
         if (file_exists("{$upload_info->upload_path}/{$state_info->file_name}")) {
             if (unlink("{$upload_info->upload_path}/{$state_info->file_name}")) {
                 $this->basic_model->db_file_delete($state_info->field_name, $state_info->file_name);
                 return true;
             } else {
                 return false;
             }
         } else {
             $this->basic_model->db_file_delete($state_info->field_name, $state_info->file_name);
             return true;
         }
     } else {
         return false;
     }
 }