200: CURL: set HTTPHEADER to upload files! (Additional Questions)

Source: Internet
Author: User
200 asked for help on how to set HTTPHEADER to upload files! (Additional questions) PHPcode $ boundarymd5 (time (); $ postStr & quot; $ postStr. & quot; -- & quot ;. $ boundary. & quot; rn & quot; $ postStr. & quot; Content-Dispos 200 points for help CURL setting HTTPHEADER file upload problems! (Additional 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"; $ postStr. = $ uploadFile. "\ r \ n"; # The content of some files $ postStr. = "--". $ boundary. "\ r \ n ";


$ PostStr. = "Content-Disposition: form-data; name = \" uptxt [] \ "; filename = \" index_1.html \ "\ r \ n ";
$ PostStr. = "Content-Type: text/html \ r \ n ";

Change

$ 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 the file successfully.


And

$ PostStr. = "Content-Disposition: form-data; name = \" uptxt [] \ "; filename = \" index_1.html \ "\ r \ n ";
$ PostStr. = "Content-Type: text/html \ r \ n ";

Change

$ PostStr. = 'content-Disposition: form-data; name = "uptxt []"; filename = "index_1.html" \ r \ n'; // it is changed to single quotation marks and \ r \ n is not escaped.
$ PostStr. = 'content-Type: text/html \ r \ n \ r \ n'; // change to single quotation marks and \ r \ n is not escaped

It can also be uploaded successfully and solved.

------ Solution --------------------
As you changed, I tested the acceptor and did not get the expected information.

Or paste the complete code to see it?
------ Solution --------------------
The agreement is to be followed. if not, the consequences are unpredictable.
You can request success, but it will make the web server mess up when parsing http. The/and line breaks are important symbol signs.

For example, the boundary block is as follows. pay attention to Content-type: text ~ Html, remove \ r \ n and replace/~
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 "; # The content of some files $ postStr. =" -- ". $ boundary." \ r \ n ";
------ Solution --------------------
Isn't curl used? I found the following online:
Perl code
    
------ Solution --------------------
Discussion
The agreement is to be followed. if not, the consequences are unpredictable.
You can request success, but it will make the web server mess up when parsing http. The/and line breaks are important symbol signs.

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.