开发者

Upload file type verification with Rails and Javascript

I'm currently working on a project where users can upload datasets in CSV format.

Is there a good way with Ruby other t开发者_JS百科han checking file extension to determine if they're really uploading a CSV and not some executable or some other file type?


You can't do this in javascript that's for sure. If you're in a UNIX environment, you can check the documentation about this.

I don't think there is any SURE way of checking this. Usually checking the file extension is fine. Plus you said you're getting CSVs, couldn't you try to parse them? If it fails, then either the document is not at the right format or it's not a csv.

Anyways, make sure that you're storing your files in a directory that has no execute access right.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜