1

I'm doing a laravel view of the editing of a record, which has an image associated with it, and I need it to appear preloaded inside the input file, so that if you submit, the same image is sent, or if you want to change it.

 // Turn input element into a pond
FilePond.registerPlugin(
    FilePondPluginFileEncode,
    FilePondPluginImagePreview,
    FilePondPluginImageExifOrientation,
    FilePondPluginFileValidateSize
);
var imagen = '{{ trim($marca->imagen_asociada) }}'
const inputElement = document.querySelector('input[type="file"]');

FilePond.setOptions({
    server: {
        load: imagen.replace('/images/button/','')
    }
});
const pond = FilePond.create(inputElement,{
    files: [
        {
            source: '{{ public_path().'/resources'.trim($marca->imagen_asociada) }}',
            options: {
                type: 'local',

                // mock file information
                file: {
                    name: imagen.replace('/images/button/',''),
                }
            }
        }
    ]
});

Now it shows like this

enter image description here

But I should show in this way enter image description here

4

2 回答 2

2

我有同样的问题,通过这个解决它:

/*FilePond.setOptions({
    server: {
        load: imagen.replace('/images/button/','')
    }
}); Remove this.*/
const pond = FilePond.create(inputElement,{
    files: [
        {
            source: '{{ public_path().'/resources'.trim($marca->imagen_asociada) }}',
            /*options: {
                type: 'local',

                // mock file information
                file: {
                    name: imagen.replace('/images/button/',''),
                }
            } - Remove this options {} dictionary */
        }
    ]
});

根据设置初始文件下的文档

于 2020-02-02T19:20:28.083 回答
0

如果您模拟文件数据,FilePond 将不会加载实际文件,并且图像预览插件将没有任何数据来显示文件。

确保您的server.load端点返回一个文件对象。

于 2019-03-01T07:47:41.070 回答