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 8470845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:37:57+00:00 2026-06-10T16:37:57+00:00

I have a slight problem here, how can I tell cURL specifically to attach

  • 0

I have a slight problem here, how can I tell cURL specifically to attach a file to a request?

If I am uploading a file with cURL, then the common method is to attach it as part of POST data array with the value having @ in front of it, for example:

CURLOPT_POSTFIELDS=>array('my-file'=>'@my-file.txt')

This would obviously work, but I have two problems with it:

  • What if it is not actually a file I am uploading? What if my POST value actually IS ‘@my-file.txt’ and it attempts to upload the file instead? It creates a loophole I am desperately trying to avoid.
  • How can I upload a file from a URL? Would I have to download it, store it in temporary folder and then attach it with @ from that temporary folder? Why can’t I give cURL just contents that I wish to use as file?

cURL CURLOPT_INFILE is not an option, since it won’t show up as part of $_FILES array.

It seems like such a loophole in cURL to be dependent on @ symbol in the POST field value. Is there a way around it? Why isn’t there a CURLOPT_FILEFIELDS array? Command-line cURL has a separate flag for this (-F), but I don’t see it as an option in PHP for some reason.

Any help would be greatly appreciated, thanks!

  • 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-06-10T16:37:59+00:00Added an answer on June 10, 2026 at 4:37 pm

    What I ended up doing is detecting if any of the input data started with an @ symbol and if they did, then submitting them as a GET variable (as part of the submit URL in cURL). It does not help with all cases (such as when a large string is submitted that starts with an @), but cuts out the problems I had with Twitter handles.

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

Sidebar

Related Questions

Hi maybe someone can help me here ... I have a slight problem with
am new here. i have a slight problem; PLease look at the following code
hey everyone, here is the site SEE BELOW I have a slight jquery problem
I have here a slight problem. We have written a big spring based application
I have a slight problem here I try to solve. As I start to
I have a slight algorithmic problem. I think I miss something but can't exactly
Hey all, have a slight problem here. In CakePHP I have a controller that
I have a slight problem with code here. I'm fairly new to it so
Got a slight problem here. I have a form for a guestbook and each
people. I have slight problem with GD2 text on image. I have everything working

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.