문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top