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