Сохранение файла с помощью завихрения и PHP

Чтобы добавить плагин Lombok IntelliJ для добавления поддержки IntelliJ в lombok:

  • Перейдите в Файл> Настройки> Плагины
  • Нажмите на Обзор репозиториев ...
  • Поиск плагина Lombok
  • Нажмите «Установить плагин»
  • Перезапустите IntelliJ IDEA
10
задан Simon East 31 March 2014 в 04:17
поделиться

3 ответа

вы хотели что-то вроде этого?

function get_file($file, $local_path, $newfilename) 
{ 
    $err_msg = ''; 
    echo "<br>Attempting message download for $file<br>"; 
    $out = fopen($local_path.$newfilename,"wb");
    if ($out == FALSE){ 
      print "File not opened<br>"; 
      exit; 
    } 

    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_FILE, $out); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_URL, $file); 

    curl_exec($ch); 
    echo "<br>Error is : ".curl_error ( $ch); 

    curl_close($ch); 
    //fclose($handle); 

}//end function 

Функциональность: Это функция и принимает три параметра

get_file($file, $local_path, $newfilename)

$ file : имя файла для извлекаемого объекта

$ local_path : локальный путь к каталогу для хранения объекта

$ newfilename : это новое имя файла в локальной системе

32
ответ дан 3 December 2019 в 14:00
поделиться

Вы можете использовать:

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
$out = curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);


$fp = fopen('data.txt', 'w');
fwrite($fp, $out);
fclose($fp);

?>

См .: http://jp2.php.net/manual/en/function.curl-exec.php и http://us3.php.net/manual/en/function.fwrite.php

9
ответ дан 3 December 2019 в 14:00
поделиться

I think curl has -o option to write the output to a file instead of stdout.

After -o you have to provide the name of the output file.

example:


curl -o path_to_the_file url
-3
ответ дан 3 December 2019 в 14:00
поделиться
Другие вопросы по тегам:

Похожие вопросы: