2012-03-26 11 views
2

私は別のサーバー はどのように他のサーバからファイルを取得し、

  • 変更したファイル名からファイルを取得するPHP

    1. で多数のタスクを実行する方法を探していたPHPでその名前を変更し、拡張子
    2. は、私は、プロキシサーバーの種類のものとして動作する方法を好むだろう

    エンドユーザーに新しいファイルをダウンロードしますが、ファイルのダウンロードにはいいと思い

    事前に0

    おかげ

  • 答えて

    0

    を参照してください必要な任意の名前でファイルの名前を変更し保存した後、この

    <?php 
        $url = 'http://www.example.com/a-large-file.zip'; 
        $path = '/path-to-file/a-large-file.zip'; 
    
        $ch = curl_init($url); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    
        $data = curl_exec($ch); 
    
        curl_close($ch); 
    
        file_put_contents($path, $data); 
    ?> 
    

    をお試しください

    これは、データを取得し、ブラウザ、ヘッダー、およびすべてに直接出力します。

    0

    あなたはtrueに設定allow_url_fopenをしている場合:

    $url = 'http://example.com/image.php'; 
    $img = '/my/folder/flower.gif'; 
    file_put_contents($img, file_get_contents($url)); 
    

    エルス使用のカールは:

    $ch = curl_init('http://example.com/image.php'); 
    $fp = fopen('/my/folder/flower.gif', 'wb'); 
    curl_setopt($ch, CURLOPT_FILE, $fp); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_exec($ch); 
    curl_close($ch); 
    fclose($fp); 
    
    0

    私はこのようなものを使用します。

    <?php 
    $url = 'http://www.some_url.com/some_file.zip'; 
    $path = '/path-to-your-file/your_filename.your_ext'; 
    
    function get_some_file($url, $path){ 
        if(!file_exists ($path)){ 
         $fp = fopen($path, 'w+'); 
         fwrite($fp, file_get_contents($url)); 
         fclose($fp); 
        } 
    } 
    ?> 
    
    +0

    おかげで、私は必要な正確に何を、ですエンドユーザにあるディスカッションの進捗バーを表示する方法があります – BDMan32

    関連する問題