Joe
Joe

Reputation: 47609

Can I restrict file types in Plupload?

I want to prevent people from trying to upload certain file types using Plupload. The documentations filters (i.e. prevent people from selecting files in the file browser) but it is still easy to get round and Plupload will allow the attempted uploading of these files:

http://www.plupload.com/documentation.php#configuration

Of course, the server then says that it doesn't want files of that type, but only after the upload has completed.

Can I get Plupload to refuse to upload files of a certain type (or only upload files of given types)?

Upvotes: 1

Views: 3305

Answers (1)

jjay225
jjay225

Reputation: 518

On the process of the fileupload or fileadd for that matter you could check the extension of the filename:

var test='hellothere.jpg';
var ext = test.substr(-3);

Then alert the user of the invalid file.

UPDATE

Additional validation will be required on the server. 1st check client side, 2nd Post to your upload method on the server side and remember if you have renamed your files look in the "name" property of the form and not the postfilecollection for the new name of your file. If theres any error you can just send json response say:

    "{"respCode" : "500", "Msg" : "Failed"}

Upvotes: 1

Related Questions