Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zastąpienie file_get_contents - zbyt duża zawartość tekstu
Mody23
post
Post #1





Grupa: Zarejestrowani
Postów: 276
Pomógł: 0
Dołączył: 30.06.2010

Ostrzeżenie: (10%)
X----


Próbuję za pomocą file_get_contents pobrać plik ważący ponad 1GB. Niestety serwer nie wyrabia. Znalazłem w necie takie oto rozwiązanie:

http://stackoverflow.com/questions/2749200...=active#tab-top

Dostaję jednak cały czas taki błąd:

Cytat
Warning: fsockopen() [function.fsockopen]: unable to connect to http://strona.pl/plik/plik.doc:80 (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in /home/


Mój kod wygląda tak:

  1. $host = "http://strona.pl/";
  2. $path = str_replace($host, "", $dwn);
  3.  
  4. $httpReq = "POST /" . $path . " HTTP/1.0\r\n";
  5. $httpReq .= "Host: ".$host."\r\n";
  6. $httpReq .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; pl; rv:1.9.1.2) Gecko/20090729 desktopsmiley_2_2_5643778701369665_44_71 DS_gamingharbor Firefox/3.5.2 (.NET CLR 3.5.30729)\r\n";
  7. $httpReq .= "Host: " . $host . "\r\n";
  8. $httpReq .= "Content-Type: text/xml\r\n";
  9. $httpReq .= "Content-Disposition: attachment; filename=\"".$filename[1]."\"\r\n\r\n";
  10.  
  11. if ($pinghandle = fsockopen($host, 80, $errno, $errstr, 30)) {
  12. fputs($pinghandle, $httpReq);
  13. while (!feof($pinghandle)) {
  14. $pingresponse .= fgets($pinghandle, 128);
  15. }
  16. fclose($pinghandle);
  17. }


jako path, podaję URI, np. download/files/my_music.mp3 bo chyba to należało tam wstawić. Mimo wszystko, kod nie działa. Może mi ktoś powiedzieć co jest nie tak?
Go to the top of the page
+Quote Post
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


wpisz samo "strona.pl/plik/plik.doc"
Go to the top of the page
+Quote Post
Mody23
post
Post #3





Grupa: Zarejestrowani
Postów: 276
Pomógł: 0
Dołączył: 30.06.2010

Ostrzeżenie: (10%)
X----


Wtedy otrzymuję "Bad Request".
Go to the top of the page
+Quote Post
com
post
Post #4





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


jak już to by było tak
"http://strona.pl:80/plik/plik.doc"

ale jak to chodzi po 80 to to jest normalne wiec nie piszesz bo poco

wiec błąd masz gdzie indziej nie lepiej było by skorzystać z cURL ?
Go to the top of the page
+Quote Post
Mody23
post
Post #5





Grupa: Zarejestrowani
Postów: 276
Pomógł: 0
Dołączył: 30.06.2010

Ostrzeżenie: (10%)
X----


Ale chodzi o to, że ja muszę pobrać plik do stringa. file_get_contents i curl zarzynają mi serwer. Muszę skorzystać z czegoś takiego, aby po kawałku pobierało ten plik po prostu.
Gdybym mógł wykorzystać CURLa to od razu bym to zrobił bo CURLa znam na wylot i nie mam problemów z jego obsługą, a tutaj walczę od 16 i dalej nic z tego nie mam :/
Go to the top of the page
+Quote Post

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: 22.08.2025 - 18:48