--- Comment #1 from Amgine <> 2011-02-14 16:34:45 UTC ---
Here is a function currently used in an extension maintenance script to
retrieve a remote file; it uses cURL which is not universally installed, stores
files in a temporary directory under the extension using a temporary name, the
former of which is fragile and writability must be tested within the script,
and returns the temporary filename or false:

function getHttpFile( $url ){
    $val = false;
    $tempName = tempnam( 'temp/', 'MyExtension' );
    if( is_writable( $tempName ) ){
        $tfh = fopen( $tempName, 'w' );
        if( is_resource( $tfh ) ){
            $ch = curl_init( $url );
            curl_setopt( $ch, CURLOPT_FILE, $tfh );
            curl_setopt( $ch, CURLOPT_HEADER, false );
            if( curl_exec( $ch ) ){
                $val = $tempName;
            curl_close( $ch );
            fclose( $tfh );
    return $val;

There are a lot of reasons this is a less-than-desirable solution.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

Wikibugs-l mailing list

Reply via email to