react-papaparse icon indicating copy to clipboard operation
react-papaparse copied to clipboard

how validate csv file only

Open jayanty3 opened this issue 5 years ago • 8 comments

jayanty3 avatar Jul 23 '20 06:07 jayanty3

@jayanty3 I don't get your point. Could you pls give me more detail? Thanks!

Bunlong avatar Jul 29 '20 03:07 Bunlong

I think what @jayanty3 is asking is: is there a way to ensure that users only upload .csv files. I would also like to know this - we don't seem to have access to the file extension in order to ignore any non-csv files.

jacobedawson avatar Sep 24 '20 12:09 jacobedawson

@jacobedawson you can use File Type while you using onFileLoaded function and just give it validation like usual.

for example :

onFileLoaded={(data, fileInfo) => console.log(data, fileInfo)} //File info has some filename or type that you can use

kurroo10 avatar Oct 05 '20 06:10 kurroo10

Thanks @bobbyrinaldy, much appreciated :)

jacobedawson avatar Oct 05 '20 11:10 jacobedawson

Any progress so far?

exaucae avatar Feb 04 '21 12:02 exaucae

@exaucae Could you try bobbyrinaldy solution?

Bunlong avatar May 31 '21 09:05 Bunlong

Yes, I did. It means we have to enforce file type by writing custom logic. It would have been nice to have it built in.

exaucae avatar May 31 '21 10:05 exaucae

Is this still valid? Issue is open but comment is from 3 years ago. And I can't find that onFileLoaded on the onFileLoaded definition, just onUploadAccepted and onUploadRejected.

And I noticed there's reference to a accept property with a sidenote on the docs about it, so maybe this should be closed as it's built in.

alex-airbox avatar May 05 '23 12:05 alex-airbox