PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
//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
?>
also i would suggest if you want to use a hidden field just use a hidden php variable as
any1 can see that field if they view the source the way it is currently
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\xampp\htdocs\php\processFiles.php on line 38
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\xampp\htdocs\php\processFiles.php on line 38
Should of showed this in the origonal post, and point out what line 38 is.. seeing how theres only 20 some shown...
1. About this: $_FILES['uploadFile'. $x]
Name your inputs "uploadFile[]", read "Uploading multiple files" in the manual.
2. You must also validate $_POST['user'] and $file_name, otherwise you've just given write access to the filesystem.
Using the user-provided name as a local filename is a generally bad idea, better generate your own filename with tempnam()