Im hosting my website on my raspberry pi. Im trying to build a website, which gives the option to upload pictures to my webserver. The structure goes like. www.URL.de/projects/nameOfTheProjects/uploads.
When I run the website with XAMPP it works but from my webserver it doesn't.
Any ideas?
<?php
//Move files to directory
$targetPath = "uploads/" . basename($_FILES["inpFile"]["name"]);
move_uploaded_file($_FILES["inpFile"]["tmp_name"], $targetPath);
?>
<form id="myForm">
<input type="file" id="inpFile"><br><br>
<button type="submit">UPLOAD</button>
</form>
</center>
<script>
const myForm = document.getElementById("myForm");
const inpFile = document.getElementById("inpFile");
myForm.addEventListener("submit", e =>{
e.preventDefault();
const endpoint = "upload.php";
const formData = new FormData();
// console.log(inpFile.files);
formData.append("inpFile", inpFile.files[0]);
//endpoin
fetch(endpoint, {
method: "post",
body: formData,
console: console.log("DONE")
}).catch(console.error);
});
</script>