Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

upload video file using ajax php

$('#save').on('click', function() {
       	$("#save").attr("disabled", true);

         var form = $('#form').val();
         var uname = $('#uname').val();
         var ufile= $('#ufile').val();

           if(uname!="" && ufile!=""){
        $(".uk-progress").show();
             $.ajax({
                 url: "include/upload.php",
                 type: "POST",
                  data:  new FormData(document.getElementById("form")),
                 contentType: false,
                 processData:false,
                 cache: false,
                 success: function(dataResult){
                    console.log(dataResult);  
                    $('#form').trigger("reset"); 
                    $('#save').removeAttr("disabled");
                     setTimeout(function(){
                       $('.uk-progress').hide();
                     }, 3000);
                    UIkit.notification({message: 'Success...', status: 'success',pos: 'bottom-center'})   

                 },
                 xhr: function() {
                var xhr = new window.XMLHttpRequest();
                xhr.upload.addEventListener("progress", function(evt) {
                    if (evt.lengthComputable) {
                        var percentComplete = Math.ceil((evt.loaded / evt.total) * 100);
                        $(".uk-progress").width(percentComplete + '%');
                        $(".uk-progress").html(percentComplete+'%');
                    }
                }, false);
                return xhr;
            },
                 error:function(dataResult){
                     console.log(dataResult);
                     $('#save').removeAttr("disabled");
                     UIkit.notification({message: 'Error...', status: 'danger',pos: 'bottom-center'})  
                 }
             });
             }else{
             	 $('#save').removeAttr("disabled");
             	 UIkit.notification({message: 'Required All Input Field...', status: 'danger',pos: 'bottom-center'})  
             }
             
        
         });
 
PREVIOUS NEXT
Tagged: #upload #video #file #ajax #php
ADD COMMENT
Topic
Name
5+2 =