Coder Social home page Coder Social logo

laravel-uploader's People

Contributors

bkstar123 avatar opaweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

laravel-uploader's Issues

Can't upload multiple files

Hi,

Thank you for your contribution. I am trying to make use of this package for multiple files upload in Laravel 8 but it is without success. In my view, I have this line here:

<input class="form-control" type="file" name="template_files[]" id="template_files" multiple>

and I loaded the following assets:

<script src="/vendor/fileupload/js/fileinput/fileinput.min.js"></script>
<link href="/vendor/fileupload/css/fileinput/fileinput.min.css" rel="stylesheet">

and the script:

<script type="text/javascript">
    $(document).ready(function(){
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $("#template_files").fileinput(
            {
                uploadUrl: '/template/store',
                data-browse-on-zone-click: true,
                dropZoneEnabled: true,
                maxFileCount: 5,
                maxFileSize: 10420, //in KBs
                allowedFileExtensions: ['jpg', 'png', 'pdf', 'html', 'htm', 'json'],
                previewFileType:'any',
                showUpload: false
            }
        ).on("filebatchselected", function(event, files) {
            $("#template_files").fileinput("upload");  
        });
    });    
</script>

In my controller, I have this:

if ($path = $this->fileupload->handle($request, 'template_files')) {
            // Persist $path data to database
            return json_encode([]);
}

return json_encode([
            'error' => $this->fileupload->uploadError
]);

But either I will have only one file uploaded when input name set to this name="template_files". If change it to name="template_files[]" for multiple files upload I will have this error:

Argument 1 passed to Bkstar123\LaravelUploader\Services\FileUpload::uploadValidate() must be an instance of Illuminate\Http\UploadedFile, array given, called in /var/www/html/my-project/vendor/bkstar123/laravel-uploader/src/Abstracts/FileUploadAbstract.php on line 52

Could you give any advice, please? Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.