var acceptFileTypes =
/^image\/(gif|jpe?g|png)$|^application\/(pdf|msword)$|^text\/plain$/i;
This seems to assume that the correct mime type is checked against acceptFileTypes
문제
I'm using blueimp File Upload plugin to upload files. There's an example regex to restrict the upload to images only:
var acceptFileTypes = /^image\/(gif|jpe?g|png)$/i;
How can I change this to upload image files, and documents like PDF, TXT, DOC?
해결책
var acceptFileTypes =
/^image\/(gif|jpe?g|png)$|^application\/(pdf|msword)$|^text\/plain$/i;
This seems to assume that the correct mime type is checked against acceptFileTypes
다른 팁
var acceptFileTypes = /^image\/(gif|jpe?g|png|pdf|doc|txt)$/i;
and make sure that these files are kept inside the image folder. so the full path to the text file should be something like /image/dsds/file.txt
if you want to add your own folder name it accordingly