Domanda

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?

È stato utile?

Soluzione

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top