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.