I am trying to write an upload script that will upload files to a certain directory. I am testing this on my windows desktop under apache if it makes a difference.
This is my code so far. Part of the target path is what the user posts to create a new directory for the uploaded file to be put into:
if($_POST['Submit']){
$target= "/uploads/".$_POST['tempName'];
if(file_exists($target)){
$msg2="That template name already exists";
}else{
mkdir($target,0777,TRUE);
$target_path = $target . basename( $_FILES['newTemp']['name']);
if(move_uploaded_file($_FILES['newTemp']['tmp_name'], $target_path)) {
$msg2= "The file ". basename( $_FILES['newTemp']['name']).
" has been uploaded".$target_path;
} else{
$msg2= "There was an error uploading the file, please try again!";
}
}
}