Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to upload multiple files using Jquery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 495
    Comment on it

    Hello Reader's!. Now multiple files on a single getting in fashion so you can use any of the multiple upload library code, But here we'll see how to use Jquery and PHP to do the same For getting it start we need a html form page and it'll go like this:-

    Ajax upload form

    <script src="//"></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        function sendfile(){
            var fd = new FormData();  
            for (var i = 0, len = document.getElementById('myfile').files.length; i < len; i++) {
                fd.append("myfile", document.getElementById('myfile').files[i]);                
              url: 'uploadfile.php',
              data: fd,
              processData: false,
              contentType: false,
              type: 'POST',      
              success: function(data){
        <form action="uploadfile.php" method="post" enctype="multipart/form-data" id="form-id">
        <p><input id="myfile" type="file" name="myfile" multiple=multiple/>
        <input type="button" name="upload" id="upload" value="Upload" onclick="sendfile()" id="upload-button-id"  /></p>

    In the above code you can see the google ajax libraries are included Now create an uploadfile.php file file and put the code below:-

        $uplolad = "targetFolder/"; 
        //for($i=0; $i <count($_FILES['myfile']['name']); $i++){
            if(move_uploaded_file($_FILES['myfile']['tmp_name'], $upload.$_FILES['myfile']['name'])) { 
                echo 'item upload to target folder'; 
                echo 'Not Upload '; //in case of any error, fail

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: