Add parameters on http POST request?


#1

I’m using a simple http POST request, along with a server-side .php file, to upload data to a server. All that works well, but I was wondering if there was any way I could add POST variables so I could pass information beyond just the file content. That is, include the equivalent of form input fields so that I could access the information via the $_POST array in PHP.


#2

Are you using background http plugin to upload file?


#3

@manojdcoder - no, just the standard http:

let content = JSON.stringify(eventData);
 http.request({
        url: eventData.subdomain + eventData.postPath,
        method: "POST",
        headers: { 
          "Content-Type": "application/octet-stream"
        },
        content: content
      }).then((response) => { ... });

#4

Then looks like you are already passing parameters, may I ask what seems to be issue still?


#5

@manojdcoder - sure. I receive the content in the .php file, but the $_POST array is empty. What I’d like to do is pass additional parameters, presumably through POST input parameters (that is, similar to what would be passed via an html form’s input fields). In particular, I’d like to pass the name of the resulting host file.