Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Dec 11th, 2012  |  syntax: None  |  size: 0.92 KB  |  hits: 39  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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);