I'm trying to use the exact same code I use elsewhere on a site that works and it's now stopped working. I don't know if it's because the directories are deeper but I can't figure it out.
For the form element I'm just using this;
<input type="file" id="logo" name="logo" required>
And for the upload code I'm using this;
<?php
$target_dir = "/home/example.com/path/files/logos/";
$target_file = $target_dir . basename($_FILES["logo"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if (move_uploaded_file($_FILES["logo"]["tmp_name"], $target_file)) {
echo "";
} else {
echo "";
}
?>
This exact method works fine with no errors at all elsewhere. I've removed validation because it isn't needed and it's not likely files will have the same names anyway. I just want to be able to upload to the directory. I'm not against appending something like _timestamp
to remove the need for validation as all files will be renamed uniquely anyway. I'm storing submitted information in a CSV and emailing a link to the image later on so this isn't needed as that would mean the new file name needs to be grabbed.
I'm facing the errors Notice: Undefined index: logo
which makes no sense to me because it's defined within the form so that's what it's grabbing that from and Notice: Trying to access array offset on value of type null in
which I still don't understand an hour into searching because no one seems to know.
Anything would be appreciated.