esbenp / fineuploader-server

MIT License
7 stars 11 forks source link

Getting error Undefined index: optimus_uploader_thumbnail_height #6

Open pushpendraas400 opened 7 years ago

pushpendraas400 commented 7 years ago

Hi: I have integrated fineuploader-server with laravel 5.4 and followed all the steps as described here https://github.com/esbenp/fineuploader-server/blob/master/README.md but getting error Undefined index: optimus_uploader_thumbnail_height.

I created following route :

Route::group(['prefix' => 'uploader'], function () {

Route::post('/upload', '\Optimus\FineuploaderServer\Controller\LaravelController@upload'); Route::delete('/delete/{uuid}', '\Optimus\FineuploaderServer\Controller\LaravelController@delete'); Route::get('/session', '\Optimus\FineuploaderServer\Controller\LaravelController@session');

}); but getting MethodNotAllowed error on Route::post('/upload', '\Optimus\FineuploaderServer\Controller\LaravelController@upload');

changing it to Route;:get and changing method to 'GET' and paramsInBody to false. This is my javascript code:

``javascript
    var restrictedUploader = new qq.FineUploader({
        element: document.getElementById("fine-uploader-validation"),
        template: 'qq-template-validation',
        request: {
            endpoint: "{{url('/').'/uploader/upload'}}",
            method: 'GET',
            paramsInBody:false
        },
        thumbnails: {
            placeholders: {
                waitingPath: "{{asset('/libraries/fine-uploader/placeholders/waiting-generic.png')}}",
                notAvailablePath: "{{asset('/libraries/fine-uploader/placeholders/not_available-generic.png')}}"
            }
        },
        validation: {
            allowedExtensions: ['jpeg', 'jpg', 'png'],
            itemLimit: 1,
            sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
        }
    });

``

where am i making mistakes ?

mblarsen commented 7 years ago

I'm having the same issue. To me, it seems there is a bug, or at least a wrong assumption, in optimus/fineuploader-server/src/Uploader.php in the merge config method.

It assumes that you are you providing this following values from the client side:

    private function mergeConfig(array $input)
    {
        $height = $input['optimus_uploader_thumbnail_height']; <----------- this one
        $width = $input['optimus_uploader_thumbnail_width'];

        if (!empty($height)) {
            $this->config->set('thumbnails.height', $height);
        }

        if (!empty($width)) {
            $this->config->set('thumbnails.width', $width);
        }
    }

Thes same problem you'll see here:

private function mergeFineUploaderConfig($input, array $config)
    {
        $allowedExtensions = $input['optimus_uploader_allowed_extensions'];

A workaround is to add these to request.params:

        request: {
          endpoint: '/uploader/upload',
          params: {
            base_directory: 'completed',
            sub_directory: null,
            optimus_uploader_allowed_extensions: [],
            optimus_uploader_size_limit: 0,
            optimus_uploader_thumbnail_height: 100,
            optimus_uploader_thumbnail_width: 100,
          }
        },