Hi I have managed to get the Jquery file upload plugin working within the Laravel framework.
I am able to set the upload_dir which is set as follows in the bundle’s config file:
return array(
'upload_dir' => path('storage').'users/',
);
This works fine although I need to obtain this URL for the callback in main.js called ‘fileuploadcompleted’, which will render the uploaded file as HTML:
.bind('fileuploadcompleted', function (e, data) {
var $filename = $.trim($('#fileupload td.name').text());
var $filePath = '../bundles/jqueryfileupload/users/';
ignore the paths above, they have just been used for testing purposes. So how can I obtain the upload_dir for use in $filePath in the callback above?
Is there a more preferred way to achieve what I’m trying to do?
I’m not sure how javascript will be able to render a file given the absolute path of your server’s upload directory. Upload dir will look something like this /var/www/vhosts/yoursite.com/storage/users.
You can probably create a route that uses file_get_contents() and your storage directory.