Run php script in nodejs server

Please Note: The TotalFreedom Forum has now been put into a read-only mode. Total Freedom has now closed down and will not be returning in any way, shape or form. It has been a pleasure to lead this community and I wish you all the best for your futures.
  • Using a simple express server, I am hosting an html file that contains a form and input tag, allowing a user to upload images. Main.js (linked to index.html) processes and sends said file to upload.php which would move the image to an uploads directory. When the fetch api calls for upload.php POST https://localhost/upload.php 404 (Not Found) is thrown. Directly accessing https://localhost/upload.php downloads upload.php to my downloads directory.

    server.js:

    index.html:

    main.js:

    upload.php:

    PHP
    <?php  
    //moves uploaded file to uploads dir  
    $targetPath = "uploads/" . basename($_FILES["inputImg"]["names"]);  
    move_uploaded_file($_FILES["inputImg"]["tmp_name"], $targetPath);  

    Index.html, main.js and upload.php are all in the same "/public" directory. As evident by https://localhost/upload.php downloading upload.php, are also able to be accessed. My goal is for the upload.php to run and succesfully move inputImg.files[0] into the /uploads directory. If somebody recognizes what I am doing wrong I would appreciate a gesture in the right direction.