Guest User

Untitled

a guest
Aug 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. cURL php download and upload without save in the middle
  2. $ch = curl_init();
  3. curl_set_opt($ch, CURLOPT_HEADERFUNCTION, 'read_header');
  4. curl_set_opt($ch, CURLOPT_WRITEFUNCTION, 'read_body');
  5.  
  6. function read_header($ch, $data) {
  7. // Ok, so the header is going to come in here.
  8. // I assume you will need data, such as MIME type and what not.
  9. print_r($data);
  10. return strlen($data); //This means that we handled it, so cURL will keep processing
  11. }
  12.  
  13. function read_body($ch, $data) {
  14. // This is where the body of the content will be, in chunks.
  15. // This function will be called multiple times.
  16. print_r($data);
  17. return strlen($data); //Again, if we don't do this, cURL will cancel.
  18. }
Add Comment
Please, Sign In to add comment