filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
19.08k stars 2.94k forks source link

Filamentphp ImportAction - Unable to import .csv file - File of invalid type - Firefox Browser #10732

Closed ARRW-Core closed 10 months ago

ARRW-Core commented 10 months ago

Package

filament/filament

Package Version

v3.1.36

Laravel Version

v10.40.0

Livewire Version

^3.3

PHP Version

PHP 8.2.13

Problem description

Screenshot_2

Cannot upload .csv file that is downloaded with download example csv file

Expected behavior

Screenshot_3

By directly changing the .csv to .txt, it is possible to upload the file.

Steps to reproduce

Reproduction repository

https://github.com/ARRW-Core/filament_csv_import_issue.git

Relevant log output

No response

petrisorcraciun commented 10 months ago

mime types for csv: 'text/csv', 'application/csv', 'text/x-comma-separated-values', 'text/x-csv'

danharrin commented 10 months ago

Thanks @petrisorcraciun, #10762

uqjohart commented 9 months ago

Updated to the latest version, it now thorws this error when trying to upload the example csv (See attached)

2024-01-15 08_42_09-Staff - SDP — Mozilla Firefox
danharrin commented 9 months ago

Please tell me the mime type of your file

uqjohart commented 9 months ago

Please tell me the mime type of your file

Just the plain old csv you get when you click on the 'Download an example csv' link provided by filament. (Filament v3.1.47)

Edit: attached staff-importer-example.csv

danharrin commented 9 months ago

I downloaded your file, uploaded it in my own project, and it worked fine. I'm gonna need more info.

uqjohart commented 9 months ago

Looks like it is only a problem on Firefox. Works on chrome and edge. Firefox must be doing something silly.

Regards,

Joshua Hartmann Senior Web Application Developer

E @.***


From: Dan Harrin @.> Sent: Monday, January 15, 2024 8:13:13 PM To: filamentphp/filament @.> Cc: Joshua Hartmann @.>; Manual @.> Subject: Re: [filamentphp/filament] Filamentphp ImportAction - Unable to import .csv file - File of invalid type - Firefox Browser (Issue #10732)

I downloaded your file, uploaded it in my own project, and it worked fine. I'm gonna need more info.

— Reply to this email directly, view it on GitHubhttps://github.com/filamentphp/filament/issues/10732#issuecomment-1891796691, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUJEZ7OMZXE65K3MCBSH2MDYOT6LTAVCNFSM6AAAAABBUEVQWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJRG44TMNRZGE. You are receiving this because you are subscribed to this thread.Message ID: @.***>

danharrin commented 9 months ago

Just tried in Firefox and it seems fine for me

notscottsmith commented 7 months ago

This is occurring with my instance of Filament - using the csv provided by the importer itself.

image

I'm using Firefox, Laravel v11, and v3.2.52 of Filament. If I rename the file to .txt it works fine. If I use Edge/Chrome, it works fine.

Firefox looks to be detecting the CSV files as "application/vnd.ms-excel" and not text/csv, et al.

https://codepen.io/GrizzlyStu/pen/YzjZjez - This allows you to interrogate the mime-type that your browser interprets it as.

image

Adding "application/vnd.ms-excel" to CanImportRecords.php solves this issue for Firefox users.

image

I created a PR for this, just in case.