Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cURL php download and upload without save in the middle
- $ch = curl_init();
- curl_set_opt($ch, CURLOPT_HEADERFUNCTION, 'read_header');
- curl_set_opt($ch, CURLOPT_WRITEFUNCTION, 'read_body');
- function read_header($ch, $data) {
- // Ok, so the header is going to come in here.
- // I assume you will need data, such as MIME type and what not.
- print_r($data);
- return strlen($data); //This means that we handled it, so cURL will keep processing
- }
- function read_body($ch, $data) {
- // This is where the body of the content will be, in chunks.
- // This function will be called multiple times.
- print_r($data);
- return strlen($data); //Again, if we don't do this, cURL will cancel.
- }
Add Comment
Please, Sign In to add comment