Uploading Script
Posted: Tue Nov 28, 2006 8:29 pm
I have an uploading script, and have a few probelms.
processFiles.php:
uploadForm1.php
I want a script that will upload files, but it doesn't work...
processFiles.php:
Code: Select all
<?
//THIS IS THE SCRIPT
//THIS IS THE SCRIPT
//THE PROCESS SCRIPT IS BELOW
//EDIT THE SCRIPT BELOW FOR INFORMATION
$uploadNeed = $_POST['uploadNeed'];
// start for loop
for($x=0;$x<$uploadNeed;$x++){
$file_name = $_FILES['uploadFile'. $x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $x]['tmp_name'],"uploads/$_POST['user']/$file_name");
// check if successfully copied
if($copy){
echo "The File $file_name was uploaded sucessfully!<br>";
}else{
echo "Sorry! The File $file_name could not be uploaded!<br>";
}
} // end of loop
//THE PHP SCRIPT ENDS HERE
?>Code: Select all
<form name="form1" method="post" action="uploadForm2.php">
<p>Enter the amount of boxes you will need below.</p>
<p>
<input name="uploadNeed" type="text" id="uploadNeed" maxlength="3" onfocus="highlight(this);" onblur="unHighlight(this);">
</p>
<td class="input"><input class="" name="pagename" onfocus="highlight(this);" onblur="unHighlight(this);" type="text"></td>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>Code: Select all
<form name="form1" enctype="multipart/form-data" method="post" action="processFiles.php">
<p>
<?
// start of dynamic form
$uploadNeed = $_POST['uploadNeed'];
for($x=0;$x<$uploadNeed;$x++){
?>
<input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
</p>
<p>
User*: <input name="user" type="text" id="user" maxlength="100">
</p>
<?
// end of for loop
}
?>
<p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
<input type="submit" name="Submit" value="Submit">
</p>
</form>