Readfile() replacement cURL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ziycon
    Contributor
    • Sep 2008
    • 384

    Readfile() replacement cURL?

    I'm unable to use the code snippet below for a file download on a site as readfile is disabled for security reasons, I'm told cURL can be used, any advice on how to change it or on the below replacement would be great, thanks.
    Code:
    header('Content-type: '.$contentType);
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    header('Content-length: '.$filesize);
    readfile($file);
    Is there any issues with using this code as a replacement or anything I should be aware of?
    Code:
    $url  = $file';
    $path = $file;
    
    $fp = fopen($path, 'w');
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_FILE, $fp);
    
    $data = curl_exec($ch);
    curl_close($ch);
    fclose($fp);
  • ziycon
    Contributor
    • Sep 2008
    • 384

    #2
    Resolved it, http://bytes.com/topic/php/answers/914960-curl-issue.

    Comment

    Working...