Jump to content

Uploading multipe files


vividona

Recommended Posts

Hi

 

Plz check this

 

<html>

<head>

<title></title>

<script type="text/javascript" language="javascript"><!--

function addfile()
   {
       //reading number of current files and putting the number in a variable
       var filesno=document.getElementById("f_no").getAttribute("value");
       filesno++;//incrementing number of files
  
        var tbody = tb.tBodies.item(0);//storing the body content of the table into a variable
        var row = document.createElement("TR");//creating a row in a new ariable
        
        var td1 = document.createElement("TD");//creating  text node "td", with the value of number of files
        td1 .appendChild (document .createTextNode (filesno));
        
        var td3 = document.createElement("TD");//creating the input control and setting it's attribute
        var file=document.createElement ('<input>');
        file.setAttribute ('type','file');
        file.setAttribute ('name','fileupload'+filesno);
        td3 .appendChild (file );//adding the file control to the table data "td"

        //adding the "TD"s we created above to the row and adding the row to the table body 
        row.appendChild(td1);
        row.appendChild(td3);
        tbody.appendChild(row);
        
        //updating the hidden input with the new number of files
    document.getElementById("f_no").setAttribute("value",filesno);
   }
   
function removefile()
   {
   //reading the number of rows in the table, ten deleting the last row
   if(tb.rows.length>2){
   tb.deleteRow(tb.rows.length-1);
   document.getElementById("f_no").setAttribute("value",document.getElementById("f_no").getAttribute("value")-1);
   }
   
   }

//--></script>


</head>

<body  style="text-align: center;color: white;background-color: gray;">
   <form action="upload.php" enctype="multipart/form-data" method="POST" >

   <input type="button" value="add file" onclick="addfile()" />
   <input type="button" value="remove file" onclick="removefile()" />
   
   <table id="tb" border="2" align="center">
   <thead>
   <tr>
   <td colspan="2">please choose files to upload</td>
   </tr>
   </thead>
   <tr><td>1.</td><td><input type="file" name="fileupload1" /></td></tr>
   </table>
    
   <input type="submit" value="upload the files" /> <input type="reset" value="clear fields" />
   <br/><br/>Amr Osama<br/>CodeCall.Net
   
   <input type="hidden" name="MAX_FILE_SIZE" value="100000000000000000000"/>
   <input  id="f_no" type="hidden" name="filesno" value="1"/>
   
  </form>
  </body>
</html>

 

This add file onclick. I need if I specified (5) multiple upload files, adding file should stop at number (5) and give warning message.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.