I've been working with Jquery File Upload and I've implemented some coffeescript that appears like this:
$('.fileupload').fileupload
dataType: "json"
add: (e, data) ->
file = data.files[0]
types = /(\.|\/)(gif|jpe?g|png)$/i
if (types.test(file.type) || types.test(file.name))
data.submit()
else
alert("Oops, " + file.name + " is not a supported filetype")
progress: (e, data) ->
done: (e, data) ->
The main goal here is to redirect files to different URLs based on their type when they are uploaded. For instance, uploading a PDF should be directed to www.website.com/process/pdf
, while images such as png/gif/jpeg should go to www.website.com/process/image
.
Can this be achieved client-side using jQuery File Upload?