12-05-16-vh
Implimenting Jquery file uploader to laravel
https://blueimp.github.io/jQuery-File-Upload/
Download the zipfile from above link
put them in public folder(I have placed in public/asset/vender/)
The server/php is the one where the important codes(index.php, uploadhandler.php) where kept.
If use that, the sessions cannot be accessed.
Best way is to make customization to the code
update main.js in /js folder of the plugin byChanging this line
url: 'server/php/'
to some controller route
eg: url: 'file_uploader'
then in the routes.php, give connection to a controller class for file_uploader'
Route::post('file_uploader', 'userController@file_uploader');
Route::get('file_uploader', 'userController@file_uploader');
Route::DELETE('file_uploader', 'userController@file_uploader');
In the userController, create a function, which can then initate the instance of the uploadHandler class(which we are going to place in seperate controller)
add this in beginnig of userController
use App\Http\Controllers\UploadHandler;
and then have this method which creates instance of UploadHandler
public function file_uploader(Request $request)
{
$upload_handler = new UploadHandler();
}
create a controller named UploadHandler, add all the namespaces and other stuffs,
copy the class UploadHandler which is there in UploadHandler.php of the plugin. Now in this UploadHandler class contrsuctor you can call Your sessions(make sure to write use Session; in beginning of controller.
For deleting file,
update $file->deleteUrl object public function set_additional_file_properties($file) and it should look like below now
$file->deleteUrl= 'file_uploader?'
.$this->get_singular_param_name()
.'='.rawurlencode($file->name);
I am posting a gross answer above, You can do some workaround to make it accessible.