200 points Curl Settings Httpheader upload file related issues! (Supplementary questions)

Source: Internet
Author: User
200 points for help Curl set Httpheader upload file Problem! (Supplementary questions)
PHP Code
  
   $boundary   = MD5 (Time ()), $postStr  = ""; $postStr. = "--". $boundary. " \ r \ n "; $postStr. =" Content-disposition:form-data; Name=\ "Uptxt[]\"; Filename=\ "index_1.html\" \ r \ n "; $postStr. =" content-type:text/html\r\n\r\n "; $postStr. = $uploadFile." \ r \ n "; #这里是部分文件内容 $postStr. = "--". $boundary. " \ r \ n ";


$postStr. = "Content-disposition:form-data; Name=\ "Uptxt[]\"; Filename=\ "index_1.html\" \ r \ n ";
$postStr. = "content-type:text/html\r\n\r\n";

Switch

$postStr. = "Content-disposition:form-data; Name=\ "Uptxt[]\"; Filename=\ "Index_1.html\" "; Delete \ r \ n
$postStr. = "Content-type:text/html"; Delete \ r \ n

After that, you can upload it successfully.


And

$postStr. = "Content-disposition:form-data; Name=\ "Uptxt[]\"; Filename=\ "index_1.html\" \ r \ n ";
$postStr. = "content-type:text/html\r\n\r\n";

Switch

$postStr. = ' Content-disposition:form-data; Name= "uptxt[]"; Filename= "index_1.html" \ r \ n ';//change to single quote, \ r \ n no longer escaped
$postStr. = ' content-type:text/html\r\n\r\n '; Change to single quote, \ r \ n no longer escaped

can also upload successfully, solve

------Solution--------------------
As you change, I test, the receiving side, not getting to the desired information

or post the full code to see?
------Solution--------------------
Agreement is to be observed, if not observed, the consequences of unpredictable.
You can request success, but will let the Web server resolve HTTP when the chaos,/number and line break are important symbol flags.

For example now boundary block, note content-type:text~html, remove \ r \ n and replace/change ~
PHP Code
$boundary = MD5 (time ()); $postStr = ""; $postStr. = "--". $boundary. " \ r \ n "; $postStr. =" Content-disposition:form-data; Name=\ "Uptxt[]\";                                                                                                       Filename=\ "Index_1.html\" "$postStr. =" Content-type:text~html "; $postStr. = "123\r\n"; #这里是部分文件内容 $postStr. = "--". $boundary. " \ r \ n ";
------Solution--------------------
Didn't you use curl? The online search for a paragraph is this:
Perl Code
    
------Solution--------------------
discuss
Agreement is to be observed, if not observed, the consequences of unpredictable.
You can request success, but will let the Web server resolve HTTP when the chaos,/number and line break are important symbol flags.
  • 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.