Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Nie moge uzyc fopen, Jak otwierac pliki za pomoca cURLa ?
radac78
post
Post #1





Grupa: Zarejestrowani
Postów: 26
Pomógł: 0
Dołączył: 21.02.2005

Ostrzeżenie: (0%)
-----


Na serwerz w php.ini wyłączona jest opcja allow_url_fopen, więc nie ma możliwości otwierania URLi przez funkcję fopen(). Jak zorbic otwarcie pliku, przy pomocy cURLa (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
hwao
post
Post #2


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




  1. <?php
  2. $fp = fsockopen(&#092;"www.example.com\", 80, $errno, $errstr, 30);
  3. if (!$fp) {
  4.  echo &#092;"$errstr ($errno)<br />n\";
  5. } else {
  6.  $out = &#092;"GET / HTTP/1.1rn\";
  7.  $out .= &#092;"Host: www.example.comrn\";
  8.  $out .= &#092;"Connection: Closernrn\";
  9.  
  10.  fwrite($fp, $out);
  11.  while (!feof($fp)) {
  12.  echo fgets($fp, 128);
  13.  }
  14.  fclose($fp);
  15. }
  16. ?>

Mozna tak, pozatym jak chcesz wiecej to masz na forum (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) (tylko szukaj + fsockopen (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) )

Co do cURL to
  1. <?php
  2. // create a new curl resource
  3. $ch = curl_init();
  4.  
  5. // set URL and other appropriate options
  6. curl_setopt($ch, CURLOPT_URL, &#092;"http://www.example.com/\");
  7. curl_setopt($ch, CURLOPT_HEADER, 0);
  8.  
  9. // grab URL and pass it to the browser
  10. curl_exec($ch);
  11.  
  12. // close curl resource, and free up system resources
  13. curl_close($ch);
  14. ?>

Na forum o tym takze bylo (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 22:25