Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1048245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:25:33+00:00 2026-05-16T16:25:33+00:00

I’m trying to post via curl, I’ve been using the same code over and

  • 0

I’m trying to post via curl, I’ve been using the same code over and over again with no problem but now I need to be able to use an array for posts (i’m not sure if there’s a proper term for that?).

I should clarify that it’s specifically a file i’m trying to post, but I can’t get it working with a string either so I don’t think it’s too do with that.

This is absouletly fine:

$uploadData = array();
$uploadData['uploads'] = "@".$file;
$uploadData['iagree'] = 'on';

This doesn’t appear to work:

$uploadData = array();
$uploadData['uploads'][0] = "@".$file;
$uploadData['iagree'] = 'on';

In the second example i’m trying to replicate an input with the attribute name=”uploads[]”

Obviously i’m trying to curl an external site, but if I experiment curling a page on my own server so that I can see what’s being sent, I can see that the uploads array is being converted to a string:

print_r($_POST);
print_r($_FILES);

returns:

Array
(
    [uploads] => Array
    [iagree] => on
)

Array
(
)

This is my full Curl:

    $uploadData = array();
    $uploadData['uploads'][] = "@".$file;
    $uploadData['iagree'] = 'on';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $theLink);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $uploadData);
    $upload_response = curl_exec($ch);
    curl_close($ch);

I’ve tried to give as much information as possible, but if i’ve missed something feel free to ask and i’ll provide more.

Other than that, does anyone have any suggestions or solutions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:25:34+00:00Added an answer on May 16, 2026 at 4:25 pm

    $uploadData['uploads[]'] = "@".$file; and passing it as an array should work, just keep in mind you need the absolute path to the file.

    There is no mechanism in ‘simple’ HTTP (multipart/form-data or application/x-www-form-urlencoded) to send ‘arrays’. However, PHP interprets the [ & ] characters in key-value pairs as special. PHP is alone in that AFAIK, it’s not a HTTP mechanism, it’s just the parsing of input PHP does, as is replacing .‘s in the name of values with _. Curl is a 3rd party package which lives seperately from PHP, and as such does not understand multidimensional arrays.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.