DELETE method for jQuery Blueimp FileUpload not allowed using Codeigniter / PHP (405 error)?

I am trying to delete files using this very nice jQuery Blueimp File Upload plugin .

I placed this plugin in my root directory and was unable to download and delete files without problems.

However, when I insert this plugin into my codeigniter application, I no longer want to delete the files downloaded due to a 405 error. I installed all the folders in 777to make sure that this is not a problem.

Any thoughts? Here is my console log:

Console.log

+5
source share
5 answers

, Codeigniter Blueimp.

URL- DELETE HTTP/AJAX, Blueimp. URL- , . , Codeigniter , URL-, , /_ .

, , :

/uploads/img1.jpg

Codeigniter uploads img1.jpg, , , .

, Blueimp "upload.class.php" file delete_url, . delete_url codeigniter/controller_method :

protected function set_file_delete_url($file) { 
    $file->delete_url = base_url().'upload/deleteFile/'.rawurlencode($file->name);
    //"upload/deleteFile is my controller/controller_method
    //$file->delete_url = $this->options['upload_url']
    //    .'?file='.rawurlencode($file->name);*/
    //.....

upload/deleteFile ( Codeigniter Blueimp Fork):

    function deleteFile($file){

    $fcpath=FCPATH.'uploads/;
    $success =unlink($fcpath.$file); //PHP function was does the actual file deletion
            //info to see if it is doing what it is supposed to 
    $info->sucess =$success;
    $info->file =is_file(FCPATH .$file);
    $info->fcpath = FCPATH;
    if (IS_AJAX) {
        //I don't think it matters if this is set but good for error checking in the console/firebug
        echo json_encode(array($info));
    }
    else {     
        //here you will need to decide what you want to show for a successful delete
        $file_data['delete_data'] = $file;
        $this->load->view('admin/delete_success', $file_data); 
     }
}
+4

UploadHandler.php:

function __construct ($ options = null, $initialize = true, $error_messages = null) {          
// "POST",          
// . , :          
//'delete_type' = > 'DELETE',           
'delete_type' = > 'POST',

+3

:

: UploadHandler.php,

:

$this->options = array(
        'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')),

$this->options = array(
        'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')).'/cargar'

, , .

+1

jquery . , . :

'script_url' => $this->get_full_url().this->basename($this->get_server_var('SCRIPT_NAME')),

SCRIPT_FILENAME

SCRIPT_FILENAME , uploadhandler.php. fileupload

'script_url' => $this->get_full_url().'/fileupload/',

. !

0

, , "script_url" "UploadHandler" , "UploadHandler".

//

$this-> options = array ('script_url' => $this-> get_full_url(). '/'. $this-> basename ($this-> get_server_var ('SCRIPT_NAME')),

//

$this-> options = array ('script_url' => base_url(). 'Admin/Categories/category_manage/picturesupload'

bonfire-CI, "admin" - "category" - , "category_manage" - . "Picturesupload" - , .

, " "/" , UploadHandler"

// "picturesupload" picturesupload() {

    error_reporting(E_ALL | E_STRICT);
    $this->load->library('UploadHandler');

}

0

All Articles