Use plupload to upload images and save them to custom folder and database table

I managed to do it by myself thanks to this tutorial.

Moved content of do.php file to a function named cmr_upload inside a class.

Then changed the plupload options from:

        url : plugin_dir + 'do.php',
        ...
        multipart_params : {
            "chapter_id": i,
            "path": path

to

        url : '<?php echo admin_url('admin-ajax.php') ?>',
        ...
        multipart_params : {
            "chapter_id": i,
            "path": path,
            "action": "cmr_upload"

Then added the function to an ajax action:

$this->loader->add_action('wp_ajax_cmr_upload', $plugin_admin, "cmr_upload"); 

tech