filepond icon indicating copy to clipboard operation
filepond copied to clipboard

File Pond is not creating the hidden fields using this code [Bug]

Open joshmanhuwa opened this issue 3 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Have you updated FilePond and its plugins?

  • [X] I have updated FilePond and its plugins

Describe the bug

The following code is expected to create a hidden field with the base64String but nothing is happening, i am not getting the base64String in the request neither as a hidden field. I am in Laravel Blade

Reproduction

    <input type="file" multiple name="image" />

    <!-- Get FilePond JavaScript and its plugins from the CDN -->
    <script src="https://unpkg.com/filepond/dist/filepond.js"></script>
    <script src="https://unpkg.com/filepond-plugin-file-encode/dist/filepond-plugin-file-encode.js"></script>
    <script src="https://unpkg.com/filepond-plugin-file-validate-size/dist/filepond-plugin-file-validate-size.js"></script>

    <!-- FilePond init script -->
    <script>

    // Register plugins
    FilePond.registerPlugin(
        FilePondPluginFileEncode,
        FilePondPluginFileValidateSize,
    );

    // Set default FilePond options
    FilePond.setOptions({

        // allow multiple files
        allowMultiple: true,

        // allow file encoding
        allowFileEncode: true,

        // maximum allowed file size
        maxFileSize: '255KB',

        // upload to this server end point
        server:{
            process: '/image-upload',
            revert: '/image-delete',
            headers: {
                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
                }
            }
    });

    // Turn a file input into a file pond
    var pond = FilePond.create(document.querySelector('input[type="file"]'));

        pond.onaddfile = (err, item) => {

        if (err) {
            console.warn(err);
            return;
        }

        const dataURL = item.getFileEncodeDataURL();

        const base64String = item.getFileEncodeBase64String();

        }

    </script>

Environment

- Device:
- OS:
- Browser:

joshmanhuwa avatar Nov 18 '22 06:11 joshmanhuwa

You need to remove server property.

rikschennink avatar Nov 18 '22 10:11 rikschennink