I'm having trouble with setting up the file upload to my php script.
Within the upload itself, I have it directed towards the path I want, but I'm not sure if I have the rest of the script syntactically right.
EDIT: I have resolved my situation with the file not properly uploading. I have edited the blocks of code to what I have currently working. If needed, please refer to the pre-edited version to see changes :).
Cheers.
$tardir= "C:/xampp/htdocs/uploaddir/$targetname";
$uploadOk=1;
if(isset($_FILES["uploadFile"])){
$tardir= $tardir . "/" . basename($_FILES["uploadFile"]["name"]);
if(move_uploaded_file($_FILES["uploadFile"]["tmp_name"], $tardir)){
echo "The file: ". basename($_FILES["uploadFile"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
The $targetname
is set to whatever the user inputs in the field. In this case, I have it as their email.
$targetname = filter_input(INPUT_POST, 'email');
This is what the <html>
for the file upload looks like:
<form action= "userlogin.php" method= "post" enctype= "multipart/form-data">
<p><strong>Please choose a file to upload: <input type="file" name="uploadFile"><br></p>
<input type="submit" value="Upload File">