Sopamo / laravel-filepond

Laravel backend module for filepond uploads
MIT License
204 stars 54 forks source link

Original file name is being lost with no way to retrieve it #30

Closed sammyaxe closed 4 years ago

sammyaxe commented 4 years ago

When files are being put on tmp folder they get renamed to something like that: laravel-filepond8BQWpd.png

any way to retrieve the orginal file name when I want to put into permanent storage?

Thanks

Sopamo commented 4 years ago

This is currently the expected behaviour. Filepond works by handling uploading the files for you, but you should take care of file metadata yourself in your own javascript. In your case you should just send the name of the original files along with the server ids to your controller. I'm going to close this issue, but feel free to ask if anything is unclear.

AltiumWilliam commented 4 years ago

When files are being put on tmp folder they get renamed to something like that: laravel-filepond8BQWpd.png

any way to retrieve the orginal file name when I want to put into permanent storage?

Thanks

Do this in you Vue components:

        <file-pond
            name="file"
            ref="pond"
            :server="server"
            @processfile="processFile" />
    methods: {
        createFileObject(file) {
            return file ? {
                id: file.id,
                fileExtension: file.fileExtension,
                fileSize: file.fileSize,
                fileType: file.fileType,
                filename: file.filename,
                filenameWithoutExtension: file.filenmeWithoutExtension,
                serverId: file.serverId
            } : ''
        },
        processFile(e, file) {
            this.localValue = this.multiple ?
                _.uniqBy(_.filter(_.concat(this.createFileObject(file),this.localValue), (file) => {
                    return _.isObject(file)
                })) :
                this.createFileObject(file);
        },
   }

Now when you upload a file to server, you have all information about uploaded file. Like this Picture

000

Now post localValue to server with Ajax!!!