2016-11-05 4 views
0

Wenn ich versuche, eine Videodatei auf Cloudinary hochzuladen und die Dateigröße auf 20 MB zu beschränken, funktioniert sie nicht richtig. Wie wendet man die Bedingung für die Beschränkung der Dateigröße an? Unten ist mein Javascript-Code und HTML-CodeDateigröße größer als 20 mb beschränken [cloudinary api]

$(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>

Antwort

Verwandte Themen