PHP Server download

Alles, was PHP betrifft, kann hier besprochen werden.

PHP Server download

Postby tromorow » 01. May 2004 21:57

Hi Jungs,

habe mal wider ein Problem!

Folgendes ich habe ein Programm programmiert mit einer automatischen Updatefunktion!
Jetzt will ich mit PHP eine Datei von einem http Server herunterladen!
Ich nutze folgenden Code:

Code: Select all
$file1 = fopen($main_system_update_updatefile,'r');
           $Server_Download_File = fread($file1,999999999999);
           $file2 = fopen('tmp/z.zip',"w");
      fwrite($file2, $Server_Download_File);
      fclose($file2);

(Die Variable $main_system_update_updatefile wird automatisch erzeugt!)

Jetzt habe ich auf dem Server eine zip Datei mit 177kb und von dieser lad er nur ca. 9kb herunter!
Wenn ich jetzt die Einlesezahl bei fread verlängere, sagt mir php das man keine negativen Zahlen verwenden dürfe!

Wo liegt der Fehler; was kann ich ändern?
Oder gibt es eine weitere (bessere) Funktion zum herunterladen?
tromorow
 
Posts: 84
Joined: 13. January 2004 18:00
Location: "Sturgot" oder auch Stuttgart (zumindes irgend wo da)

Postby Wiedmann » 01. May 2004 22:21

Wenn du das unter WIndows machst, ist es eine gute Idee PHP zu sagen das du da eine Binär-Datei hast:
Code: Select all
$Server_Download_File = '';
$file1 = fopen($main_system_update_updatefile, 'rb');
while(!feof($file1)) {
   $Server_Download_File = $Server_Download_File.fread($file1, 1024);
}
fclose($file1);
$file2 = fopen('tmp/z.zip', 'wb');
fwrite($file2, $Server_Download_File);
fclose($file2);


Ist aber nicht getestet... Und auf Fehler zu Prüfen wär auch noch ne gute Idee.
Last edited by Wiedmann on 01. May 2004 23:03, edited 1 time in total.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby tromorow » 01. May 2004 22:50

Hi Wiedmann,

vielen dank!
tromorow
 
Posts: 84
Joined: 13. January 2004 18:00
Location: "Sturgot" oder auch Stuttgart (zumindes irgend wo da)

Super !!!

Postby guybrush82 » 24. May 2005 06:15

Coole Sache! Das hat mir auch echt super geholfen.

Also Dateien am besten immer Binär einlesen, das hat bisher immer geklappt !!!

Danke! Der Thomas :-)
Wie nennt man nen Programmierer auf dem Nordpol? -> ASCIIMO !!!
User avatar
guybrush82
 
Posts: 28
Joined: 02. December 2003 13:46
Location: Erfurt


Return to PHP

Who is online

Users browsing this forum: No registered users and 20 guests