Upload unlimited files
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Upload unlimited files
If you view the source of the pages with your browser, you will see that the PHP code is quite absent
. That's caused by the fact that PHP is a server side language, and invisible to the client. You'd have to ZIP the files, that way Apache doesn't try to tell PHP to process it
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
Isn't it sad that I have learned how to read all that code, but didn't know such a core concept.
I've listed the form code first, and then the form processing code second. There is some extra junk code, but the basic concept is there. If anyone knows a little javascript and can tell me how to make the Add More button add the drop-down lists next to the Browse button, feel free to share.
FORM CODE
FORM PROC CODE:
I've listed the form code first, and then the form processing code second. There is some extra junk code, but the basic concept is there. If anyone knows a little javascript and can tell me how to make the Add More button add the drop-down lists next to the Browse button, feel free to share.
FORM CODE
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
//<![CDATA[
function dothat() {
var div = document.getElementById('fileuploads');
var field = div.getElementsByTagName('input')[0];
div.appendChild(document.createElement("br"));
div.appendChild(field.cloneNode(false));
}
//]]>
</script>
<link href="/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="tester_processor_multifileupload.php" method="post" enctype="multipart/form-data">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="body_css">
<tr>
<td colspan="2"><strong>Name:</strong></td>
<td colspan="2"> </td>
</tr>
<tr>
<td width="75"><label for="fname">First:</label></td>
<td width="215"><input type="text" name="fname" id="fname" /></td>
<td width="75"><label for="lname">Last:</label></td>
<td width="311"><input type="text" name="lname" id="lname" /></td>
</tr>
<tr>
<td><label for="phone">Phone:</label></td>
<td>
<input type="text" name="phone" id="phone" /></td>
<td><label for="email">E-mail:</label></td>
<td><input name="email" type="text" id="email" size="40" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="4"><strong>Upload Files</strong></td>
</tr>
<tr>
<td colspan="4"> <div id="fileuploads">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="39%"> </td>
<td width="30%"><strong>Grade Level:</strong></td>
<td width="31%"><strong>Subject:</strong></td>
</tr>
<tr>
<td><input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
<td><select name="grade" id="grade">
<option>Please Select</option>
<option>Pre-K</option>
<option>Kindergarten</option>
<option>1st Grade</option>
<option>2nd Grade</option>
<option>3rd Grade</option>
<option>4th Grade</option>
<option>5th Grade</option>
<option>6th Grade</option>
<option>7th Grade</option>
<option>8th Grade</option>
<option>9th Grade</option>
<option>10th Grade</option>
<option>11th Grade</option>
<option>12th Grade</option>
<option>Post-Secondary</option>
</select></td>
<td><select name="subject" id="subject">
<option value="">Please select</option>
<option value="1">Biology</option>
<option value="2">Character Education</option>
<option value="3">Chemistry</option>
<option value="4">Classroom Management</option>
<option value="5">Communications</option>
<option value="6">Economics</option>
<option value="7">Education</option>
<option value="8">Engineering</option>
<option value="9">English</option>
<option value="10">ESL</option>
<option value="11">Finance</option>
<option value="12">Fine Arts</option>
<option value="13">Foreign Language</option>
<option value="14">Health & Phys Ed</option>
<option value="15">History</option>
<option value="16">International Studies</option>
<option value="17">Law</option>
<option value="18">Management</option>
<option value="19">Marketing</option>
<option value="20">Mathematics</option>
<option value="21">Medical/Nursing</option>
<option value="22">Reading</option>
<option value="23">Religious Studies</option>
<option value="24">Physics</option>
<option value="25">Social Studies</option>
<option value="26">Special Education</option>
<option value="27">Science</option>
<option value="28">Sociology</option>
<option value="29">Study Skills</option>
<option value="30">Training Resources</option>
<option value="31">Technology</option>
<option value="32">Vocational Education</option>
<option value="33">Not Subject Specific</option>
</select></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td colspan="4"><input type="button" name="addmore" id="addmore" value="Add More" onClick="dothat();" />
<input type="submit" name="button" id="button" value="Submit" /></td>
</tr>
</table>
<p>
</p>
</form>
</body>
</html>Code: Select all
<html>
<body>
<?php
$filetemp = $_POST['file'];
echo "<pre>";
print_r($_FILES['ufile']['name'][0]);
echo "</pre>";
echo "<hr />";
?>
</body>
</html>
<?php
//set where you want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
echo "<br>";
echo "<br>";
$num_cat = count ($_FILES['ufile']['name']);
echo "number of files: " . "$num_cat";
echo "<br>";
echo "<br>";
for ($i = 0; $i < $num_cat; $i++)
{
$path1= "upload/".$_FILES['ufile']['name'][$i];
echo "$path1 <br>";
//copy file to where you want to store file
copy($_FILES['ufile']['tmp_name'][$i], $path1);
//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$_FILES['ufile']['name'][$i]."<BR/>";
echo "File Size :".$_FILES['ufile']['size'][$i]."<BR/>";
echo "File Type :".$_FILES['ufile']['type'][$i]."<BR/>";
echo "<img src=\"$path1\" width=\"150\" height=\"150\">";
echo "<P>";
///////////////////////////////////////////////////////
// Use this code to display the error or success.
$filesize=$_FILES['ufile']['size'][$i];
if($filesize != 0)
{
echo "We have recieved your file(s)";
}
else {
echo "ERROR.....";
}
//////////////////////////////////////////////
// What files that have a problem? (if found)
if($filesize==0) {
echo "There is an error in uploading your file(s).";
echo "<BR />";
}
}
?>
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
i figured out how to dynamically duplicate an entire row using javascript. I used the third example in the tutorial below:
http://www.mredkj.com/tutorials/tablebasics3.html
I'll now end the posting to this thread to avoid hijacking my own thread.
http://www.mredkj.com/tutorials/tablebasics3.html
I'll now end the posting to this thread to avoid hijacking my own thread.