kills Geschrieben 16. September 2004 Geschrieben 16. September 2004 Hallo zusammen, vorneweg, ich kann kein CGI bzw. Perl ich bin auf der suche nach einem Perl FileUpload Script. Bei google hab ich dazu diese Beispiel gefunden: #!/usr/bin/perl ### NOTE: this is to demonstrate binary file upload, text file uploading is simple, but if you want to know how to do textfile uploading, just remove all the binmode() functions and that's it! use CGI; ### Set Maximum Upload size to 2MB (prevent ppl from uploading extremely large files or other such malicious stuff) $CGI::POST_MAX = 2048; print "content-type: text/html\n\n"; ### Set Standard Input to Binary Mode (this is critical for binary data (e.g. images) - the key piece of this code which nobody tells you (except me)) binmode(STDIN); @inx = <STDIN>; ### This is just for a single file upload.. you can improve the code to include boundary separations and stuff like that.. ### These two lines delete the boundary and file info which comes with the formfeed and leaves only the binary data splice(@inx,0,4); splice(@inx,$#inx,1); $in = join("",@inx); $in = substr($in,0,length($in) - 2);; ### This next sniplet assumes you are uploading a JPEG file and saves it as z.jpg in the folder this script is stored ### You can also further improve the script by retreiving the filename from the 'spliced' lines open(ff,">z.jpg"); ### Set file output to binary mode (since you're assuming to write a binary file) binmode(ff); print ff $in; close(ff); print "DONE, Uploaded Size: ".length($in)." bytes"; [/PHP] Nun sieht das für mich so aus, als könnte dieses Script nur im binärmodus Files Uploaden. Wie muss ich es modifizieren um alle arten von Files uploaden zu können? Danke im vorraus
alligator Geschrieben 16. September 2004 Geschrieben 16. September 2004 Hi, du kannst prinzipiell im binmode alle Files übertragen. Aber wenn du sie als Ascii übertragen willst (zum Steuerzeichen konvertieren), dann lass die Funktionen binmode(STDIN); binmode(ff); einfach weg. Musst halt vorher ne Abfrage machen, ob es ein Text-File ist oder nicht und dann halt die dementsprechende Verzweigung. cya alligator
dr.disk Geschrieben 16. September 2004 Geschrieben 16. September 2004 binmode ist ein Schalter der nur unter Windows funktioniert - unter allen andern Systemen wird der nicht beachet und hat keine Wirkung (und kann deswegen ignoriert werden). Unter Windows sollte er halt stehen, damit die Dateioperationen genauso funktionieren wie nicht unter Windows. Fazit: las's stehen - macht doch eh nix
Empfohlene Beiträge
Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren
Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können
Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!
Neues Benutzerkonto erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde Dich hier an.
Jetzt anmelden