public function importFromRemote($overwrite = true, array $options = array()) {
        if (!function_exists('curl_init')) {
            throw new RuntimeException('The cURL module is required for remote file importing');
        }

        $url = $this->_data;
        $name = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_BASENAME);

        if (!$name) {
            $name = md5(microtime(true));
        }

        $options = $options + array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_FAILONERROR => true,
            CURLOPT_SSL_VERIFYPEER => false
        );

        // Fetch the remote file
        $curl = curl_init($url);
        curl_setopt_array($curl, $options);
        $response = curl_exec($curl);
        $error = curl_error($curl);
        curl_close($curl);

        // Save the file locally
        if (!$error) {
            $target = $this->findDestination($name, $overwrite);

            if (file_put_contents($target, $response)) {
                $this->_file = new File($target);

                return true;
            }
        }

        throw new IoException(sprintf('Failed to import %s from remote location: %s', $name, $error));
    }
public function importFromRemote($overwrite = true, array $options = array()) {
        if (!function_exists('curl_init')) {
            throw new RuntimeException('The cURL module is required for remote file importing');
        }

        $url = $this->_data;
        $name = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_BASENAME);

        if (!$name) {
            $name = md5(microtime(true));
        }

        $options = $options + array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_FAILONERROR => true,
            CURLOPT_SSL_VERIFYPEER => false
        );

        // Fetch the remote file
        $curl = curl_init($url);
        curl_setopt_array($curl, $options);
        $response = curl_exec($curl);
        $error = curl_error($curl);
        curl_close($curl);

        // Save the file locally
        if (!$error) {
            $target = $this->findDestination($name, $overwrite);

            if (file_put_contents($target, $response)) {
                $this->_file = new File($target);

                return true;
            }
        }

        throw new IoException(sprintf('Failed to import %s from remote location: %s', $name, $error));
    }
public function importFromRemote ( $ overwrite = true , array $ options = array ( ) ) { if ( ! function_exists ( 'curl_init' ) ) { throw new RuntimeException ( 'The cURL module is required for remote file importing' ) ; } $ url = $ this -> _data ; $ name = pathinfo ( parse_url ( $ url , PHP_URL_PATH ) , PATHINFO_BASENAME ) ; if ( ! $ name ) { $ name = md5 ( microtime ( true ) ) ; } $ options = $ options + array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_FOLLOWLOCATION => true , CURLOPT_FAILONERROR => true , CURLOPT_SSL_VERIFYPEER => false ) ; // Fetch the remote file $ curl = curl_init ( $ url ) ; curl_setopt_array ( $ curl , $ options ) ; $ response = curl_exec ( $ curl ) ; $ error = curl_error ( $ curl ) ; curl_close ( $ curl ) ; // Save the file locally if ( ! $ error ) { $ target = $ this -> findDestination ( $ name , $ overwrite ) ; if ( file_put_contents ( $ target , $ response ) ) { $ this -> _file = new File ( $ target ) ; return true ; } } throw new IoException ( sprintf ( 'Failed to import %s from remote location: %s' , $ name , $ error ) ) ; }
Copy a remote file to the temp directory and return a File object.

@param bool $overwrite
@param array $options
@return bool
@throws \Transit\Exception\IoException
@throws \RuntimeException
Copy a remote file to the temp directory and return a File object .