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

181
Views
How to upload & pass variables to the same php file

I try uploading a text file from client desktop to a server. A web page is built on js like this:

const usunDane = document.getElementById('cbxUsunDane').checked;
const nadpiszDane = document.getElementById('cbxNadpiszDane').checked;

formData.append("file", selectedFile);
formData.append("usunDane", usunDane);
formData.append("nadpiszDane", nadpiszDane);

   await fetch('php/produktyUpload.php', {
     method: "POST", 
     body: formData
   });

I added usunDane and nadpiszDane hoping to pass it into produktyUpload.php file, however I do not know how to properly read it. I tried this:

if ($_FILES['nadpiszDane']=="true") {
    error_log("UPDATE ", 3, "/var/www/html/errors.log");
} else {
    error_log("INSERT ", 3, "/var/www/html/errors.log");
}

... but this does not work.

When I look at the browser I can see that both variables are passed to php file... * Content-Disposition: form-data; name="usunDane" true

Content-Disposition: form-data; name="nadpiszDane" true *

Could someone please advice on how to pass/read these variables?

about 4 years ago · Juan Pablo Isaza
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!