basic upload widget-javascript
HTML
<a href="#" id="upload_widget_opener">Upload multiple images</a>
<!--Step 1: Replace the script URL-->
<!--<script src="https://widget.cloudinary.com/global/all.js" type="text/javascript"></script> -->
<script src="https://widget.cloudinary.com/v2.0/global/all.js" type="text/javascript"></script>
<script type="text/javascript">
//Step 2.1: Declare your uploadwidget variable
var myUploadWidget;
var fileSize
document.getElementById("upload_widget_opener").addEventListener("click", function() {
myUploadWidget = cloudinary.openUploadWidget({
cloudName: "<cloud name>",
uploadPreset: "<upload preset>",
client_allowed_formats: ["jpg", "jpeg", "mp4", "png"],
//Step 3: Add list of sources that should be added as tabs in the widget.
sources: [
"local",
"url",
"camera"
],
max_file_size:fileSize
if( client_allowed_formats==="mp4"){
fileSize=5000000
}
},
function(error, result) {
//Step 2.3: Listen to 'success' event
if (result.event === "success") {
//Step 2.4: Call the .close() method in order to close the widget
myUploadWidget.close();
}
});
}, false);
//Step 2.2: Call the .open() method in order to open the widget
myUploadWidget.open();
</script>