Im trying to upload a file but i keep getting the sent to an object not found page error 404.
Im guessing that it is due to my path directory being wrong and the error exist between 'localhost' and C:\xampp\htdocs\PHP
Thanks in advance
My PHP code
<?php
$target_dir = "..\upload";
$target_file = $target_dir.basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$uploadError = "Error";
$fileType = pathinfo($target_file,PATHINFO_EXTENSION);
if(isset($_POST["submit"])) {
$uploadOk = 1;
}
if (file_exists($target_file)) {
$uploadOk = 0;
$uploadError = "Sorry, file already exists.";}
if ($_FILES["fileToUpload"]["size"] > 100000) {
$uploadOk = 0;
$uploadError = "Sorry, your file is too large.";}
if($fileType != "txt" ) {
$uploadOk = 0;
$uploadError = "Sorry, only NOW TXT files are allowed.";}
if ($uploadOk == 0) {
echo $uploadError;} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}}?>
My HTML
<form action=".php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Submit" name="submit">
</form>