Expand|Select|Wrap|Line Numbers
- <script language="javascript" type="text/javascript">
- function addField() {
- var tbody = document.getElementById("tblBody");
- var ctr = tbody.getElementsByTagName("input").length + 1;
- var input;
- if ( ctr > 75 ) {
- alert ("The maximum number of images has been reached.");
- }else{
- if (document.all){ //input.name doesn't work in IE
- input = document.createElement('<input name="images[]">');
- }else{
- input = document.createElement('input');
- input.name = "images[]";
- }
- input.id = input.name;
- input.type = "file";
- input.value = "";
- input.className = "images[]";
- var cell = document.createElement('td');
- cell.style.height = '30px';
- cell.appendChild(document.createTextNode(ctr+". "));
- cell.appendChild(input);
- var row = document.createElement('tr');
- row.appendChild(cell);
- tbody.appendChild(row);
- window.document.the_form.count.value = ctr;
- }
- }
- </script>
- <body>
- <form name="the_form" id="the_form" method="POST" action="addimgck.php" enctype="multipart/form-data">
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tbody id="tblBody">
- <tr>
- <td height="30">
- 1. <input name="images[]" type="file" class="imgfield" id="field_1" />
- </td>
- </tr>
- <tr>
- <td height="30">
- 2. <input name="images[]" type="file" class="imgfield" id="field_2" />
- </td>
- </tr>
- <tr>
- <td height="30">
- 3. <input name="images[]" type="file" class="imgfield" id="field_3" />
- </td>
- </tr>
- <tr>
- <td height="30">
- 4. <input name="images[]" type="file" class="imgfield" id="field_4" />
- </td>
- </tr>
- <tr>
- <td height="30">
- 5. <input name="images[]" type="file" class="imgfield" id="field_5" />
- </td>
- </tr>
- </table>
- <input name="count" type="hidden" id="count" value="4"/>
- <input type="hidden" name="returnURL" id="returnURL" value="<?php print $returnURL;?>" />
- <input type="hidden" name="ID" id="ID" value="<?php print $random_digit;?>" />
- <input name="add" type="button" class="button" id="add" value="Add Image(s)" onClick="addField();"/>
- <input name="Submit" type="submit" value="Upload Image" />
- </form>
Expand|Select|Wrap|Line Numbers
- while(list($key,$value) = each($_FILES['images']['name']))
- {
- if(!empty($value))
- {
- $filename = $value;
- $filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
- $add = "upload/imgtemp/m/$random_digit/$filename";
- $tempFLDR = "upload/imgtemp/t/$random_digit/$filename";
- //echo $_FILES['images']['type'][$key];
- // echo "<br>";
- copy($_FILES['images']['tmp_name'][$key], $add);
- chmod("$add",0777);
- copy($_FILES['images']['tmp_name'][$key], $tempFLDR);
- chmod("$tempFLDR",0777);