file input only upload last selected image

Web Tips Q & ACategory: Krajee Pluginsfile input only upload last selected image
wmtoscar asked 4 weeks ago

I’m working with bootstrap-fileinput in Codeigniter as I want to upload multiple files (either it can be multiple images, videos or files) and as mentioned there I have done the following code

 class="form-group">  for="attachments">  id="attachment" name="attachment[]" type="file" class="file" multiple> 

        uploadUrl: '#',
        uploadAsync: false,
        showCaption: false,
        fileActionSettings: {
            showRemove: true,
            showUpload: false,
            showZoom: true,
            showDrag: false
        allowedFileExtensions: ["jpg", "jpeg", "gif", "png", "mp4", "txt", "docx", "pptx", "xlsx", "pdf", "ppt", "xls", "doc"],
        overwriteInitial: false,
        initialPreviewAsData: true, // identify if you are sending preview data only and not the raw markup
        initialPreviewFileType: 'image', // image is the default and can be overridden in config below
        purifyHtml: true // this by default purifies HTML data for preview
    }).on('filesorted', function (e, params) {
        console.log('File sorted params', params);
    }).on('fileuploaded', function (e, params) {
        console.log('File uploaded params', params);

But the above code is not working properly as I'm only getting the last selected image instead of getting all the selected image.

I have also tried the solution mentioned on this SO post but that too didn’t worked.
PS: I don’t want to upload files via ajax I just want to preview all my selected files and when I press submit button I want all those files to be uploaded.
What I’m doing wrong here?


Login or register to contribute or comment.

Login   Register