Error Dropzone uploading images to server

Viewed 82

When I drop the images to the dropzone area it's not uploading and gives me error "Failed to load resource: the server responded with a status of 500 (Internal Server Error)" Picture over here

enter image description here

I'm using Laravel 8 and Dropzone 5.9.2

In ArticleController

public function imageUpload(Request $request)
    {
        $secretCode = $request->input('secretCode');
        $fileName = $request->file('file')->store("public/temp/{$secretCode}");

        dispatch(new ResizeImage(
            $fileName,
            120,
            120
        ));

        session()->push("images.{$secretCode}", $fileName);

        return response()->json(
            [
                'id' => $fileName
            ] 
        ); 
    }

And this is my js file


    if($('#drophere').length >0 ){
       
        let csrfToken = $('meta[name="csrf-token"]').attr('content');
        let secretCode = $('input[name="secretCode"]').attr('value');
        
       

        let myDropzone = new Dropzone('#drophere', {
            url: '/article/images/upload',

            params: {
                _token: csrfToken,
                secretCode: secretCode
            },

            addRemoveLinks: true,

            init: function() {
                $.ajax({
                    type: 'GET',
                    url: '/article/images',
                    data: {
                        secretCode:secretCode
                    },
                    dataType: 'json'
                }).done(function(data){
                    $.each(data, function(key, value){
                        let file = {
                            serverId: value.id
                        };

                        myDropzone.options.addedfile.call(myDropzone, file);
                        myDropzone.options.thumbnail.call(myDropzone, file, value.scr);
                    });
                });
            }
        });

        myDropzone.on("success", function(file,response){
            file.serverId = response.id;
        })
    
        myDropzone.on("delete", function(file){
           
            $.ajax({
                type: 'DELETE',
                url: '/article/images/remove',
                data: {
                    _token: csrfToken,
                    secretCode: secretCode,
                    id: file.serverId
                },
                dataType: 'JSON'
            });
    
        });
        
    }
  
    
});```

Thank you in advance for the help. 
0 Answers
Related