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

  • Home
  • SEARCH
  • 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 6325529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:54:45+00:00 2026-05-24T16:54:45+00:00

Im trying to post to a multipart html form using CURLs CURLOPT_POSTFIELDS, but I

  • 0

Im trying to post to a multipart html form using CURLs CURLOPT_POSTFIELDS, but I cannot find out how to post it with no files.

When testing the form in normal browser, the “File” field can be empty, “Name” and “Message” can not.

This works:

$array = array(
 "Name" => "Jon",
 "Message" => "My package was broken, please send new.",
 "File" => "@look_omg_its_broken_omgomg_look_at_the_corners.jpg"
);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $array);

This doesnt:

$array = array(
 "Name" => "Jon",
 "Message" => "My package was broken, please send new.",
 "File" => ""
);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $array);
$output = curl_exec($ch);

This last $output results in a bool(false)
I have also tried these variations of values, but no success.

"File" => "@"
"File" => "@/"
"File" => NULL
"File"
"File" => array("")
"File" => array("filename" => "")

Anyone know better?

  • 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-24T16:54:46+00:00Added an answer on May 24, 2026 at 4:54 pm

    Without refactoring your backend or emulating a multi-part form submission manually I’m pretty sure you won’t be able to solve your problem with any CURLOPT_POSTFIELDS logic alone, also see:

    • http_request_body_encode
    • Generating multipart boundary
    • userland multipart/form-data handler

    If you insist on trying to solve this using CURL alone, I suggest you inspect the ext/curl source code.

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

Sidebar

Related Questions

I'm trying to POST some data as if I was using FORM on HTML
I am trying to post a multi-part form using httplib, url is hosted on
I'm trying to POST a http request using ajax, but getting a response from
I am using html form below and on my local computer trying to upload
I am trying to have a HTML form post a file to a Asp
I am trying so sniff a multi-part POST request using Wireshark. When viewing the
I am trying to POST a HTML (contained in a file) to a URL
I'm trying to post some code on a blog using the pre tag. Something
I'm trying to post to the login form of an application on another subdomain
I'm trying to post to a webpage using WebClient in C#. Somehow the parameters

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.