Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
Can't upload files to webserver from website with js/php

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>
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!