Why can't I delete a sentence to upload a file using curl in php?

Source: Internet
Author: User
{Code ...} the code is as above. Why can't post be executed if & amp; lt; inputtype & quot; text & quot; name & quot; fname & quot; & amp; gt; is deleted?
   
  '@'.realpath($path).";filename=".$filename);        $ch = curl_init();        curl_setopt($ch, CURLOPT_URL, $url);        curl_setopt($ch, CURLOPT_POST, true );        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);        curl_setopt($ch, CURLOPT_HEADER, false);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        $return_data = curl_exec($ch);        curl_close($ch);        $decode = json_decode($return_data);        echo $decode->original_pic;         }    if ($_POST) {        $url = 'https://127.0.0.1/img.php';        $tmpname = $_FILES['fname']['name'];        $tmpfile = $_FILES['fname']['tmp_name'];        upload_file($url,$tmpname,$tmpfile);        exit;    }    echo '';?>

Why do I delete the code above?Cannot execute post?

Reply content:
   
  '@'.realpath($path).";filename=".$filename);        $ch = curl_init();        curl_setopt($ch, CURLOPT_URL, $url);        curl_setopt($ch, CURLOPT_POST, true );        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);        curl_setopt($ch, CURLOPT_HEADER, false);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        $return_data = curl_exec($ch);        curl_close($ch);        $decode = json_decode($return_data);        echo $decode->original_pic;         }    if ($_POST) {        $url = 'https://127.0.0.1/img.php';        $tmpname = $_FILES['fname']['name'];        $tmpfile = $_FILES['fname']['tmp_name'];        upload_file($url,$tmpname,$tmpfile);        exit;    }    echo '';?>

Why do I delete the code above?Cannot execute post?

Is there any error message! Paste it to see

... There should be an error. is it null to return the result? You can only open a breakpoint to see if there is a problem at that step.

The uploaded file information should be put in $ _ FILES instead of $ _ POST. then, there will be nothing in your post and $ _ POST will be printed in advance.

No documentation found. it's just a test. you can set a name for submit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.