0

Im new to AJAX but good with PHP and doing a php/ajax project for a video upload. the AJAX side of things work fine but the file doesn't upload to the folder. below is the code sample. Thank you for your help in advance.

`

 <script type="text/javascript">
function uploadfile(){
var file = _('file1').files[0];
    alert(file.size);
    var formdata = new FormData();
    formdata.append("file1", file);
    var ajax = new XMLHttpRequest();
   // ajax.upload.addEventListener("progress", progressHandler,false);
   // ajax.addEventListener("load", completeHandler,false);
    //ajax.addEventListener("error", errorHandler,false);
    //ajax.addEventListener("abort", abortHandler,false);
    ajax.open("POST","process.php");
    ajax.send(formdata);
    }
         function completeHandler(){
            _('perc').innerHTML = "Upload Complete."; 
         }
         
         function errorHandler(){
            _('perc').innerHTML = "An error occured, Upload failed.";   
         }
         
         function abortHandler(){ 
             
         }
         
         function progressHandler(event){
             
             var perc = Math.round((event.loaded / event.total) * 100);
             _('progressbar').value = perc;
             _('perc').innerHTML = perc + "% uploaded";
             //_('status').innerHTML = "uploaded " + event.loaded + " bytes of " + event.total + "uploaded.";
         }
    
        function _(el){
            return document.getElementById(el);
        }
        
</script>`
S4NDM4N
  • 904
  • 2
  • 11
  • 26
  • 3
    You look at the console and the network tab – Masivuye Cokile Aug 22 '17 at 10:19
  • oh sorry, Here's the php code, the upload progress bar works fine, it reads the file name, size, etc. everything from the html to Ajax works as expected. I just added a redirect to the php script using a header/location function still it didnt redirect. is there another way to check if the AJAX is communicating with the PHP script? – Lucky Agbaroji Aug 22 '17 at 10:33

0 Answers0