filepond icon indicating copy to clipboard operation
filepond copied to clipboard

[Bug] fileExtension incorrect if file has no extension

Open aabenraa opened this issue 1 year ago • 2 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

I'm finding that if I upload a file that has no extension (i.e., no "dot-something" at the end of the file name), when I use the fileExtension getter on the item, I get the full filename rather than an empty string. I'm working around it by comparing the results of fileExtension and filename, and if they're the same, proceed assuming there is actually is no extension.

Reproduction

I make a filepond instance like this:

const pond = FilePond.create(inputElement, {
  allowMultiple: true,
  instantUpload: true,
  allowRevert: true,
  allowRemove: false,
  allowReorder: true,
  dropOnPage: true,
  dropOnElement: false,
  maxParallelUploads: 10,
  server: {
    process: './do_file_upload.php',
    fetch: null,
    revert: './do_file_revert.php',
  }
});

then I catch the submit button click event for the form that the file input element is in, use pond.getfiles() to get the file list, and loop through looking at item.fileExtension among other things. If there is a file in the list without an extension, the results of item.filenameWithoutExtension and item.fileExtension are the same, and equal to the name of the uploaded file.

Environment

- Device: HP DL380 G8
- OS: Ubuntu 22.04.1 LTS
- Browser: Chrome 104.0.5112.101 on Win 10 19044.1889

aabenraa avatar Aug 17 '22 20:08 aabenraa

this is something I'm picking up in v5 of filepond

rikschennink avatar Sep 19 '22 06:09 rikschennink

Thanks!

From: Rik @.> Sent: Sunday, September 18, 2022 11:46 PM To: pqina/filepond @.> Cc: aabenraa @.>; Author @.> Subject: Re: [pqina/filepond] [Bug] fileExtension incorrect if file has no extension (Issue #857)

this is something I'm picking up in v5 of filepond

— Reply to this email directly, view it on GitHub https://github.com/pqina/filepond/issues/857#issuecomment-1250629579 , or unsubscribe https://github.com/notifications/unsubscribe-auth/A2SMHQELIBVWJTE6JQS7XA3V7AD4LANCNFSM562ZIP3A . You are receiving this because you authored the thread.Message ID: @.***>

aabenraa avatar Sep 19 '22 17:09 aabenraa