javascriptzipajax-upload

Uploading Zipped folder Using Ajax Upload


In my site I want to upload a zipped folder using ajax.

Code:

<script type="text/javascript">
    $(function(){
     var btnUpload=$('#file_mod');
        new AjaxUpload(btnUpload, {
            action: "index.php",
            name: 'file',
            onSubmit: function(file, ext){
            //alert(file);
                if (! (ext && /^(jpg|png|jpeg|gif|JPG|PNG|JPEG|GIF)$/.test(ext))){
                    // extension is not allowed 
                    return false;
                }           
            },
            onComplete: function(file, response){
            alert("success");
            }
     });
 </script>

But I don't know how ajax is used for zipped file uploading.

What should I change in my code?


Solution

  • According to this code you should add .zip extension to your allow list.

    if (! (ext && /^(zip|ZIP)$/.test(ext))){
        // extension is not allowed 
        return false;
    }
    

    Now it should also upload zip files.

    Hope this answer helps you in any way.