Advertisement
Guest User

Untitled

a guest
Dec 11th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. <?php
  3. $header = <<<heredoc
  4. POST /index.php HTTP/1.1\r\nUser-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5\r\nHost: nginx.selfimpr.org\r\nAccept: */*\r\nContent-Length: %d\r\nContent-Type: multipart/form-data; boundary=----------------------------4db878605894; charset=utf-8\r\n\r\n
  5. heredoc;
  6. /* notice here */
  7. /* if I change the header Content-Type to "Content-Type: multipart/form-data; boundary=----------------------------4db878605894\r\n", it will work fine */
  8.  
  9. $body = <<<heredoc
  10. ------------------------------4db878605894\r\nContent-Disposition: form-data; name="image"; filename="big.jpg"\r\nContent-Type: image/jpeg\r\n\r\n
  11. heredoc;
  12.  
  13. $body .= file_get_contents('/Users/selfimpr/big.jpg');
  14. $body .= "\r\n-----------------------------4db878605894--\r\n";
  15. $header = sprintf($header, strlen($body));
  16.  
  17.  
  18. $fp = fsockopen('nginx.selfimpr.org', 80);
  19. fwrite($fp, $header . $body);
  20. echo fread($fp, 4096);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement