i'm using multer, multer-azure-storage, and blueimp-file-upload. all served from unpkg.com. below is a multiple file upload with the done trigger. working as of 10/22/17.
js file:
<script src="https://unpkg.com/[email protected]/dist/jquery.min.js"></script>
<script src="https://unpkg.com/[email protected]/js/vendor/jquery.ui.widget.js"></script>
<script src="https://unpkg.com/[email protected]/js/jquery.iframe-transport.js"></script>
<script src="https://unpkg.com/[email protected]/js/jquery.fileupload.js"></script>
page html, served from express:
$('#fileupload').fileupload({
url: 'https://domainwhatevs/my-listings/edit/[property id]/gallery',
paramName: '_file',
dataType: 'json',
type: 'POST',
autoUpload: true,
add: function (e, data) {
console.log('uploading:', data)
data.submit();
},
done: function (e, data) {
console.log('done triggered');
console.log(data._response.result.result[0].originalname, 'uploaded at', data._response.result.result[0].url);
$.each(data.files, function (index, file) {
// console.log(file.name, 'uploaded.')
// console.log('done');
// console.log(index);
// console.log(file);
});
console.log(data);
}
});
// GET /my-listings/edit/[property id]/gallery
app.get(
[
'/my-listings/edit/:_id/gallery'
],
(req, res) => {
console.log('image gallery:', req.params._id);
res.render('my-listings--edit--gallery', {
_id: req.params._id,
session: req.session
});
}
);
// POST /my-listings/edit/[property id]/gallery
app.post(
[
'/my-listings/edit/:_id/gallery'
],
upload.array('_file'),
(req, res, next) => {
console.log(req.files);
res.setHeader('Content-Type', 'application/json');
res.send({result: req.files});
next();
}
);