![](/img/trans.png)
[英]Google chrome crashing while uploading larger files using (event.target as FileReader).result . (File size greater than 80mb)
[英]restrict uploading file size greater than 20 mb [cloudinary api]
當我嘗試將視頻文件上傳到cloudinary並將文件大小限制為20mb時,它無法正常工作。 如何應用限制文件大小的條件? 以下是我的JavaScript代碼和html代碼
$(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") } });
<form> <input name="file" type="file" id="upload_file" accept="video/mp4,video/x-m4v,video/*"> <input type="text" name="cloudinary_response" id="cloudinary_response"> </form>
限制視頻大小是一項內置功能。 您所需要做的就是設置maxFileSize
參數,如下所示:
https://github.com/cloudinary/cloudinary_js#client-side-image-resizing-before-upload
請確保按照文檔中的說明以正確的順序導入所需的JS文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.