当我尝试将视频文件上传到cloudinary并将文件大小限制为20mb时,它无法正常工作。如何应用文件大小限制的条件?以下是我的javascript代码和HTML代码
Period
$(document).ready(function() {
$('.progress').hide();
$('#cloudinary_response').hide();
});
$('#upload_file').bind('change', function() {
var file_size = this.files[0].size;
if (file_size < 200000) {
$('#upload_file').unsigned_cloudinary_upload('xyz', {
cloud_name: 'xyz',
tags: 'upload'
}).bind('cloudinarydone', function(e, data) {
public_id = data.result.public_id;
}).bind('cloudinarystart', function(e, data) {
$('.progress').show();
transform = {
cloud_name: 'xyz'
};
}).bind('cloudinaryprogress', function(e, data) {
$('.progress-bar').css('width',
Math.round((data.loaded * 100.0) / data.total) + '%')
});
} else {
alert("File size is greater than 20MB")
}
});
答案 0 :(得分:0)
限制视频大小可作为内置功能使用。您所要做的就是设置maxFileSize
参数,如下所示:
https://github.com/cloudinary/cloudinary_js#client-side-image-resizing-before-upload
确保导入所需的JS文件(按正确的顺序),如文档中所述。