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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:04:37+00:00 2026-05-13T12:04:37+00:00

I have built a php script which receives values in $_POST and $_FILES I’m

  • 0

I have built a php script which receives values in $_POST and $_FILES

I’m catching those values, and then trying to use CURL to make posts to FogBugz.

I can get text fields to work, but not files.

    $request_url = "http://fogbugz.icarusstudios.com/fogbugz/api.php";

            $newTicket = array();
            $newTicket['cmd'] = 'new';
            $newTicket['token'] = $token;
            $newTicket['sPersonAssignedTo'] = 'autobugz';

            $text = "\n";
            foreach( $form as $pair ) {
                $text .= $pair[2] . ": " . $pair[0] . "\n";
            }
            $text = htmlentities( $text );
            $newTicket['sEvent'] = $text;

            $f = 0;
            foreach ($_FILES as $fk => $v) {
                if ($_FILES[$fk]['tmp_name'] != '') {
                    $extension = pathinfo( $_FILES[$fk]['name'], PATHINFO_EXTENSION);
                    //only take the files we have specified above
                    if (in_array( array( $fk, $extension ) , $uploads)) {
                        $newTicket['File'.$f] = $_FILES[$fk]['tmp_name'];
                        //echo ( $_FILES[$fk]['name'] );
                        //echo ( $_FILES[$fk]['tmp_name'] );
                        //print $fk;
                        //print '<br/>';
                        //print_r( $v );
                    }
                }
            }

            $ch = curl_init( $request_url );
            $timeout = 5;
            curl_setopt($ch, CURLOPT_POST,1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $newTicket );
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $data = curl_exec($ch);
            curl_close($ch);
  • 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-13T12:04:37+00:00Added an answer on May 13, 2026 at 12:04 pm

    To upload files with CURL you should prepend a @ to the path, see this example:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
    curl_setopt($ch, CURLOPT_URL, _VIRUS_SCAN_URL);
    curl_setopt($ch, CURLOPT_POST, true);
    // same as <input type="file" name="file_box">
    $post = array(
        "file_box"=>"@/path/to/myfile.jpg",
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
    $response = curl_exec($ch);
    

    Taken from http://dtbaker.com.au/random-bits/uploading-a-file-using-curl-in-php.html.

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

Sidebar

Ask A Question

Stats

  • Questions 337k
  • Answers 337k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can create a Payments Pro account in the sandbox.… May 14, 2026 at 4:06 am
  • Editorial Team
    Editorial Team added an answer http://www.vb-helper.com/howto_net_localize_at_runtime.html Got it solved with this example. May 14, 2026 at 4:06 am
  • Editorial Team
    Editorial Team added an answer I was sort of there, but the View needs to… May 14, 2026 at 4:06 am

Related Questions

I am currently creating a type of classifieds website, and when the user enters
I've been trying to build a simple prototype application in Django, and am reaching
I've built a news site: - The articles are shown on the front page
I have a script which at one point returns an image thumbnail using jquery
I have been following the post below trying to hook my SubVersion installation to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.