<?php
$max_uploads=10;
$path=$rel_dir;
?>
<script>
function addRow() {
               		document.form1.count.value = parseInt(document.form1.count.value) + 1;
               		var i = parseInt(document.form1.count.value);
  	         		var table;
	                   if (document.all)
	                     table = document.all.uploadtable;
	                   else if (document.getElementById)
	                     table = document.getElementById('uploadtable');
	                   if (table && table.rows && table.insertRow) {
	                     var tr = table.insertRow(table.rows.length);
	                     var td = tr.insertCell(tr.cells.length);
                         data = '<input type="file" name="upload' + i + '" class="textboxgray"><br>';
	                     td.innerHTML = data;
	                   }
	                }
</script>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="f7f7f7">
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
        <tr bgcolor="#FFFFFF">
          <td width="20%" bgcolor="fafafa">File Upload Path </td>
          <td colspan="3" bgcolor="fafafa"><?php echo $path; ?></td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td></td>
          <td width="44%"></td>
          <td width="21%">&nbsp;</td>
          <td width="15%">&nbsp;</td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td colspan="4">
            <?php

                if(isset($_POST['count'])){
	            	$count = $_POST['count'];

            	for($i = 1; $i < $count + 1; $i++){


							if(isset($HTTP_POST_FILES["upload".$i]) && $HTTP_POST_FILES["upload".$i]["name"] != "")
							{

                        	    echo "<br>File Upload Status ..";
                        	    $fname=$HTTP_POST_FILES["upload".$i]["name"];
	                            $tname=$HTTP_POST_FILES["upload".$i]["tmp_name"];
	                            if($fname=="")continue;
                                	if(move_uploaded_file($tname, $base_dir.$path."/".$fname))
	                                {
	                                	echo "<br>".$fname." was success fully uploaded !!! ";
	                                } else {
	                                	echo "<br>".$fname." could not be uploaded !!! ";
	                                }

							}

				}
				}
						?>
          </td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td colspan="4"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
              <tr>
                <td><center>
                    <strong> </strong>
                    <form name="form1" enctype="multipart/form-data" method="post" action="admin.php?page=fm&fmaction=upload&upload=true&rel_dir=<?php echo $rel_dir; ?>">
					<table border="0" cellspacing="1" cellpadding="2" id="uploadtable">
                      <tr>
                        <td>

                            <strong>
                            <input type="file" name="upload1" class="textboxgray">
                            </strong> </td>
                      </tr>
                      </table>
                      <table border="0" cellspacing="1" cellpadding="2">
                      <tr>
                        <td></td>
                        <td> <strong>
                          <div align="right"><BR>
                            <input type="button" name="add" value="More files ?" class="textboxgray" onClick="javascript: addRow()">
                            &nbsp;&nbsp;&nbsp;<input class="textboxgray" type="button" name="Button" value="Back" onClick="window.location='admin.php?page=fm&rel_dir=<?php echo $rel_dir; ?>'">
                            &nbsp;&nbsp;&nbsp;<input type="submit" name="Submit" value="Upload" class="textboxgray"></div>
                          </strong></td>
                      </tr>

                    <input type="hidden" name="count" value="1">
                    </table></form>
                    <strong></strong>
</center></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<br>