datei upload
Übersicht

AppartBetreff: datei upload |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hi
Ich versuche jetzt schon seit einigen Tagen mit bb ein bild auf meinen webspace zu laden. Ich benutze dafür folgendes php-script. Code: [AUSKLAPPEN] <h1>Upload</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <input type="file" name="probe" /> <input type="submit" value="Los!" /> </form> <hr /> <?php if (isset($_FILES['probe']) and ! $_FILES['probe']['error']) { // Alternativ: and $_FILES['probe']['size'] move_uploaded_file($_FILES['probe']['tmp_name'], "./newfile.gif"); printf("Die Datei %s steht jetzt als " . "newfile.txt zur Verfügung.<br />\n", $_FILES['probe']['name']); printf("Sie ist %u Bytes groß und vom Typ %s.<br />\n", $_FILES['probe']['size'], $_FILES['probe']['type']); } ?> jetzt weiss ich jedoch nicht wie ich dass bild "übergeben" soll , da mein ansatzt nicht funktioniert. Ansatz: Code: [AUSKLAPPEN] tcp = OpenTCPStream("idaxd.cwsurf.de",80) datei = OpenFile("test.gif") While Not Eof(datei) a = a+ (3 + Len(ReadLine(datei))) Wend Print a WriteLine tcp,"POST http://idaxd.cwsurf.de/test.html HTTP 1.0" WriteLine tcp,"Host: idaxd.cwsurf.de" WriteLine tcp,"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8" WriteLine tcp,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" WriteLine tcp,"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" WriteLine tcp,"Accept-Encoding: gzip,deflate" WriteLine tcp,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" WriteLine tcp,"Keep-Alive: 300" WriteLine tcp,"Connection: keep-alive" WriteLine tcp,"Referer: http://idaxd.cwsurf.de/test.html" WriteLine tcp,"Content-Type: multipart/form-data;" WriteLine tcp,"Content-Length: "+a WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"Content-Disposition: form-data; name="+Chr(34)+"probe"+Chr(34)+"; filename="+Chr(34)+"test.GIF"+Chr(34)+"" WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"" CloseFile(datei) datei = OpenFile("test.gif") While Not Eof(datei) WriteLine tcp,ReadLine(datei) Wend CloseFile(datei) WriteLine tcp,"" While Not Eof(tcp) Print ReadLine(tcp) Wend WaitKey() Ausser dem Hab ich mir noch angeschaut was firefox sendet: Code: [AUSKLAPPEN] http://idaxd.cwsurf.de/test.html POST /test.html HTTP/1.1 Host: idaxd.cwsurf.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://idaxd.cwsurf.de/test.html Content-Type: multipart/form-data; boundary=---------------------------3195204853093 Content-Length: 233042 -----------------------------3195204853093 Content-Disposition: form-data; name="probe"; filename="test.GIF" Content-Type: image/gif GIF89a€`÷ HTTP/1.x 200 OK Date: Sat, 04 Apr 2009 12:06:05 GMT Server: Apache/2.2.3 (Debian) mod_dbi_pool/0.1.0 mod_vhost_dbi/0.1.0 X-Powered-By: PHP/5.2.9 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=ISO-8859-1 ---------------------------------------------------------- Ich hoffe ihr wisst was mein Fehler ist. MFG Appart |
||
![]() |
HolzchopfMeisterpacker |
![]() Antworten mit Zitat ![]() |
---|---|---|
Sieht so aus, als ob du den Header nicht richtig schicken würdest... zB seh ich bei dir kein boundary, und Filename überträgst du auch nicht.
Und übertrag das Bild byteweise, nicht Zeilenweise, da ein Zeilenumbruch auf einigen Systemen Chr(10)+Chr(13) ist und auf anderen nur Chr(10) - dh: Aus deiner Datei werden uU die Bytekombinationen 10+13 zu 10, was bei Dateien, die nicht textbasiert sind, unlesbar macht. mfG |
||
Erledige alles Schritt um Schritt - erledige alles. - Holzchopf
CC BY ♫ BinaryBorn - Yogurt ♫ (31.10.2018) Im Kopf da knackt's und knistert's sturm - 's ist kein Gedanke, nur ein Wurm |
Appart |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
mhh ich hab es jetzt mit readbyte versucht und ich sende jetzt auch boundary mit jedoch ohne erfolg.
Code: [AUSKLAPPEN] tcp = OpenTCPStream("idaxd.cwsurf.de",80) datei = OpenFile("test.gif") While Not Eof(datei) a = a+Len(ReadLine(datei)) Wend CloseFile(datei) Print a WriteLine tcp,"POST http://idaxd.cwsurf.de/test.html HTTP 1.0" WriteLine tcp,"Host: idaxd.cwsurf.de" WriteLine tcp,"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8" WriteLine tcp,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" WriteLine tcp,"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" WriteLine tcp,"Accept-Encoding: gzip,deflate" WriteLine tcp,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" WriteLine tcp,"Keep-Alive: 300" WriteLine tcp,"Connection: keep-alive" WriteLine tcp,"Referer: http://idaxd.cwsurf.de/test.html" WriteLine tcp,"Content-Type: multipart/form-data; boundary=---------------------------41184676334" WriteLine tcp,"-----------------------------41184676334" WriteLine tcp,"Content-Length: "+a+"" WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"Content-Disposition: form-data; name="+Chr(34)+"probe"+Chr(34)+"; filename="+Chr(34)+"test.GIF"+Chr(34)+"" WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"" datei = OpenFile("test.gif") While Not Eof(datei) WriteLine tcp,ReadByte(datei) Wend CloseFile(datei) WriteLine tcp,"" While Not Eof(tcp) Print ReadLine(tcp) Wend WaitKey() mfg |
||
![]() |
Eingeproggt |
![]() Antworten mit Zitat ![]() |
---|---|---|
Glaub zwar nicht unbedingt, dass es daran liegt, aber du gibst den HTTP-Header falsch (bzw anders) an:
Du sendest: HTTP 1.0 Firefox sendet: HTTP/1.1 Wäre übrigens interessant, die Antwort des Servers zu wissen... Also nach dem Senden einfach: Code: [AUSKLAPPEN] While Not Eof(stream)
Debuglog ReadLine(stream) Wend |
||
Gewinner des BCC 18, 33 und 65 sowie MiniBCC 9 |
Appart |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Das ist irgendwie komisch wenn ich mir den Inhalt wie folgt anzeigen lassen will kommt garnichts
Code: [AUSKLAPPEN] tcp = OpenTCPStream("idaxd.cwsurf.de",80) datei = OpenFile("test.gif") While Not Eof(datei) a = a+Len(ReadLine(datei)) Wend CloseFile(datei) Print a WriteLine tcp,"POST http://idaxd.cwsurf.de/test.html HTTP 1.1" WriteLine tcp,"Host: idaxd.cwsurf.de" WriteLine tcp,"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8" WriteLine tcp,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" WriteLine tcp,"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" WriteLine tcp,"Accept-Encoding: gzip,deflate" WriteLine tcp,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" WriteLine tcp,"Keep-Alive: 300" WriteLine tcp,"Connection: keep-alive" WriteLine tcp,"Referer: http://idaxd.cwsurf.de/test.html" WriteLine tcp,"Content-Type: multipart/form-data; boundary=---------------------------41184676334" WriteLine tcp,"-----------------------------41184676334" WriteLine tcp,"Content-Length: "+a+"" WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"Content-Disposition: form-data; name="+Chr(34)+"probe"+Chr(34)+"; filename="+Chr(34)+"test.GIF"+Chr(34)+"" WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"" datei = OpenFile("test.gif") While Not Eof(datei) WriteLine tcp,ReadByte(datei) Wend CloseFile(datei) WriteLine tcp,"" ; ;Hier wird aus gelesen was vom Server kommt While Not Eof(tcp) DebugLog ReadLine(tcp) Wend WaitKey() Wenn ich jedoch die while schleife an eine andere Stelle sete geht es Code: [AUSKLAPPEN] tcp = OpenTCPStream("idaxd.cwsurf.de",80) datei = OpenFile("test.gif") While Not Eof(datei) a = a+Len(ReadLine(datei)) Wend CloseFile(datei) Print a WriteLine tcp,"POST http://idaxd.cwsurf.de/test.html HTTP 1.1" WriteLine tcp,"Host: idaxd.cwsurf.de" WriteLine tcp,"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8" WriteLine tcp,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" WriteLine tcp,"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" WriteLine tcp,"Accept-Encoding: gzip,deflate" WriteLine tcp,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" WriteLine tcp,"Keep-Alive: 300" WriteLine tcp,"Connection: keep-alive" WriteLine tcp,"Referer: http://idaxd.cwsurf.de/test.html" WriteLine tcp,"Content-Type: multipart/form-data; boundary=---------------------------41184676334" WriteLine tcp,"-----------------------------41184676334" WriteLine tcp,"Content-Length: "+a+"" WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"Content-Disposition: form-data; name="+Chr(34)+"probe"+Chr(34)+"; filename="+Chr(34)+"test.GIF"+Chr(34)+"" WriteLine tcp,"Content-Type: image/gif" WriteLine tcp,"" ; ;Hier wird aus gelesen was vom Server kommt While Not Eof(tcp) DebugLog ReadLine(tcp) Wend datei = OpenFile("test.gif") While Not Eof(datei) WriteLine tcp,ReadByte(datei) Wend CloseFile(datei) WriteLine tcp,"" WaitKey() Mfg Appart |
||
![]() |
HolzchopfMeisterpacker |
![]() Antworten mit Zitat ![]() |
---|---|---|
So, weil ich grad ne soziale Ader an mir entdeckt hab (unds mich selber eig auch interessiert), hab ich kurz geschaut, was mir ff denn wirklich sendet, wenn ich ein multipart-formdata Formular abschicke...
Mein kleiner "Server" Code: [AUSKLAPPEN] Local TCPServer = CreateTCPServer( 80 )
Local TCPStream Type TTCPConnection Field Stream End Type Local TCPConnection.TTCPConnection While Not KeyDown(1) TCPStream = AcceptTCPStream( TCPServer ) If TCPStream TCPConnection = New TTCPConnection TCPConnection\Stream = TCPStream EndIf For TCPConnection = Each TTCPConnection Local txt$ While ReadAvail( TCPConnection\Stream ) txt$ = txt$ +Chr( ReadByte( TCPConnection\Stream ) ) If Right( txt$, 2 ) = Chr(13) +Chr(10) DebugLog Replace( txt$, Chr(13) +Chr(10), "\r\n" ) +" " +( Len( txt$ ) ) txt$ = "" EndIf Wend Next Wend End Html-Zeugs Code: [AUSKLAPPEN] <html>
<head> <title></title> </head> <body> <form action="http://localhost/" enctype="multipart/form-data" method="post" accept-charset="ISO-8859-1"> Dateiname:<br /> <input type="file" name="datei" size="50" /><br /> <input type="submit" name="fileupload" value="Upload" /> </form> <form action="http://localhost/" enctype="multipart/form-data" method="post" accept-charset="ISO-8859-1"> <input type="input" name="eingabe" size="50" /><br /> <input type="hidden" name="eingabe2" value="12345" /> <input type="submit" name="test" value="Absenden" /> </form> </body> </html> Und das empfängt der Server, wenn ich das untere Formular abschicke Zitat: POST / HTTP/1.1\r\n 17
Host: localhost\r\n 17 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8\r\n 101 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n 73 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n 54 Accept-Encoding: gzip,deflate\r\n 31 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n 48 Keep-Alive: 300\r\n 17 Connection: keep-alive\r\n 24 Content-Type: multipart/form-data; boundary=---------------------------221901842288\r\n 85 Content-Length: 352\r\n 21 \r\n 2 -----------------------------221901842288\r\n 43 Content-Disposition: form-data; name="eingabe"\r\n 48 \r\n 2 Hallo Welt!\r\n 13 -----------------------------221901842288\r\n 43 Content-Disposition: form-data; name="eingabe2"\r\n 49 \r\n 2 12345\r\n 7 -----------------------------221901842288\r\n 43 Content-Disposition: form-data; name="test"\r\n 45 \r\n 2 Absenden\r\n 10 -----------------------------221901842288--\r\n 45 Wie man sieht, ist Content-Length die grösse der Daten und wird vor dem ersten boundary geschickt. Danach kommt eine Leerzeile und dann fängt der Inhalt an, eingeleitet von einem boundary, abgeschlossen von einem boundary +"--" - ob die "--" sein müssen weiss ich nicht. Ich kann dir auch nicht sagen, wie der boundary aufgebaut sein muss, Google war mir leider nicht Freund genug und drum hab ich da nix genaueres drüber herausgefunden. Ach ja, die "\r\n" werden natürlich nicht so übertragen, das sind eigentlich Chr(13)+Chr(10) (Windowsvariante von Zeilenvorschub) die ich einfach sichtbar haben wollte. Auch die Zahlen hinter den Zeilen werden nicht übertragen, das ist jeweils die Länge der Zeile (inkl Zeilenvorschub) um die Contentgrösse nachrechnen zu können. Und wenn man eine kleine Datei überträgt, Zitat: POST / HTTP/1.1\r\n 17
Host: localhost\r\n 17 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8\r\n 101 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n 73 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n 54 Accept-Encoding: gzip,deflate\r\n 31 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n 48 Keep-Alive: 300\r\n 17 Connection: keep-alive\r\n 24 Content-Type: multipart/form-data; boundary=---------------------------3010690408942\r\n 86 Content-Length: 490\r\n 21 \r\n 2 -----------------------------3010690408942\r\n 44 Content-Disposition: form-data; name="datei"; filename="s200.txt"\r\n 67 Content-Type: text/plain\r\n 26 \r\n 2 SetBuffer BackBuffer()While 1Cls:For i=1To 8z=4If i=1z=2ElseIf i=4Or i=7z=3\r\n 77 If i Mod 3For j=1To z:Oval 50+30*i,100+30*(4-j),30,30,Mid(Right(Bin(Mid(CurrentTime(),i,1)),4),5-j,1)Next\r\n 107 Next:Flip:Wend\r\n 16 -----------------------------3010690408942\r\n 44 Content-Disposition: form-data; name="fileupload"\r\n 51 \r\n 2 Upload\r\n 8 -----------------------------3010690408942--\r\n 46 Fazit: 1. Bei dir ist der Header einfach noch falsch aufgebaut 2. Vorsicht beim rumprobieren! Ich hab mir gestern (und auch schon vor Jahren mal, als ichs ebenfalls ausprobiert habe) den Netzwerkadapter mehrmals gekillt, als ich versucht habe, irgendwie multipart-formdatas an einen Server zu übermitteln und dabei die content-length nicht richtig angab und kein abschliessendes boundary hatte. mfG Edit ~~ gelöscht ~~ Edit 2 Funktionierenden Quellcode gibts weiter unten Ich hoffe, ich hab dir nicht zu viel Müll auf den Webspace geladen =) |
||
- Zuletzt bearbeitet von Holzchopf am Mo, Apr 06, 2009 9:45, insgesamt 2-mal bearbeitet
Appart |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Erstmal viieeln Dank =)
Jedoch bekomme ich vom server immer nur den html - source als antwort , wenn ich diesen source verwende: Code: [AUSKLAPPEN] Global Boundary$ = "-----------------------------" +MilliSecs() Global NewLine$ = Chr(13) +Chr(10) Local tcp = OpenTCPStream("idaxd.cwsurf.de",80) Local FPath$ = "C:\" Local FName$ = "test.gif" Local FSize = FileSize( FPath +FName ) ; Inhalt zusammenstellen ; muss vorläufig gemacht werden, um die grösse im Header angeben zu können Local Content$ Content = Boundary +NewLine Content = Content + "Content-Disposition: form-Data; name="+Chr(34)+"probe"+Chr(34)+"; filename="+Chr(34)+FName+Chr(34) +NewLine Content = Content + "Content-Type: image/gif" +NewLine Content = Content + NewLine Local File = OpenFile( FPath +FName ) While Not Eof( File ) Content = Content +Chr( ReadByte( File ) ) Wend CloseFile( File ) Content = Content + NewLine Content = Content + Boundary +"--" +NewLine ; Header schicken WriteLine tcp,"POST http://idaxd.cwsurf.de/test.html HTTP/1.1" WriteLine tcp,"Host: idaxd.cwsurf.de" WriteLine tcp,"User-Agent: Godmode" WriteLine tcp,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" WriteLine tcp,"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" WriteLine tcp,"Accept-Encoding: gzip,deflate" WriteLine tcp,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" WriteLine tcp,"Keep-Alive: 300" WriteLine tcp,"Connection: keep-alive" WriteLine tcp,"Referer: http://idaxd.cwsurf.de/test.html" WriteLine tcp,"Content-Type: multipart/form-data; boundary=" +Boundary WriteLine tcp,"Content-Length: " + Len( Content ) WriteLine tcp,"" WriteLine tcp,Content ;Hier wird aus gelesen was vom Server kommt While Not KeyDown(1) If ReadAvail( tcp ) DebugLog ReadLine(tcp) EndIf Wend CloseTCPStream tcp End Mfg appart |
||
Appart |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Tut mir leid das ich nochmal poste aber ich verstehe leider nicht was am folgenden Code falsch sein soll.
Code: [AUSKLAPPEN] Global Boundary$ = "-----------------------------" +MilliSecs() Global NewLine$ = Chr(13) +Chr(10) Local tcp = OpenTCPStream("idaxd.cwsurf.de",80) Local FSize = FileSize( "C:\test.txt") ; Inhalt zusammenstellen ; muss vorläufig gemacht werden, um die grösse im Header angeben zu können Local Content$ Content = Boundary +NewLine Content = Content + "Content-Disposition: form-Data; name="+Chr(34)+"probe"+Chr(34)+"; filename="+Chr(34)+"test.txt"+Chr(34) +NewLine Content = Content + "Content-Type: text/plain" +NewLine Content = Content + NewLine Local File = OpenFile( "C:\test.txt" ) While Not Eof( File ) Content = Content +Chr( ReadByte( File ) ) DebugLog Content Wend ; Header schicken WriteLine tcp,"POST http://idaxd.cwsurf.de/test.html HTTP/1.1" WriteLine tcp,"Host: idaxd.cwsurf.de" WriteLine tcp,"User-Agent: Godmode" WriteLine tcp,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" WriteLine tcp,"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" WriteLine tcp,"Accept-Encoding: gzip,deflate" WriteLine tcp,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" WriteLine tcp,"Keep-Alive: 300" WriteLine tcp,"Connection: keep-alive" WriteLine tcp,"Referer: http://idaxd.cwsurf.de/test.html" WriteLine tcp,"Content-Type: multipart/form-data; boundary=" +Boundary WriteLine tcp,"Content-Length: " + Len( Content ) WriteLine tcp,"" WriteLine tcp,Content WriteLine tcp,Content = Content + NewLine WriteLine tcp,Boundary +"--" +NewLine While Not KeyDown(1) If ReadAvail( tcp ) DebugLog ReadLine(tcp) EndIf Wend CloseTCPStream tcp End Und das ist die Antwort vom Server Code: [AUSKLAPPEN] HTTP/1.1 200 OK Date: Sun, 05 Apr 2009 20:30:27 GMT Server: Apache/2.2.3 (Debian) mod_dbi_pool/0.1.0 mod_vhost_dbi/0.1.0 X-Powered-By: PHP/5.2.9 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=ISO-8859-1 b5 <h1>Upload</h1> <form action="/test.html" method="post" enctype="multipart/form-data"> <input type="file" name="probe" /> <input type="submit" value="Los!" /> </form> <hr /> 0 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>501 Method Not Implemented</title> </head><body> <h1>Method Not Implemented</h1> <p>0 to / not supported.<br /> </p> </body></html> Mfg Appart |
||
![]() |
HolzchopfMeisterpacker |
![]() Antworten mit Zitat ![]() |
---|---|---|
Wahhh :O
Jetzt aber: Code: [AUSKLAPPEN] Global Boundary$ = "------------------------------" +MilliSecs()
Global NewLine$ = Chr(13) +Chr(10) Local tcp = OpenTCPStream("idaxd.cwsurf.de",80) ;Local tcp = OpenTCPStream("localhost",80) Local FPath$ = "H:\Bilder\" Local FName$ = "explosion.gif" Local FSize = FileSize( FPath +FName ) ; Inhalt zusammenstellen ; muss vorläufig gemacht werden, um die grösse im Header angeben zu können Local Content$ Content = "--" +Boundary +NewLine Content = Content + "Content-Disposition: form-Data; name="+Chr(34)+"probe"+Chr(34)+"; filename="+Chr(34)+FName+Chr(34) +NewLine Content = Content + "Content-Type: image/gif" +NewLine Content = Content + NewLine Local File = OpenFile( FPath +FName ) While Not Eof( File ) Content = Content +Chr( ReadByte( File ) ) Wend CloseFile( File ) Content = Content + NewLine Content = Content + "--" +Boundary +"--" ; Header schicken WriteLine tcp,"POST /test.html HTTP/1.1" WriteLine tcp,"Host: idaxd.cwsurf.de" ;WriteLine tcp,"POST / HTTP/1.1" ;WriteLine tcp,"Host: localhost" WriteLine tcp,"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4" WriteLine tcp,"Accept: Text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" WriteLine tcp,"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" WriteLine tcp,"Accept-Encoding: gzip,deflate" WriteLine tcp,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" WriteLine tcp,"Keep-Alive: 300" WriteLine tcp,"Connection: keep-alive" WriteLine tcp,"Content-Type: multipart/form-data; boundary=" +Boundary WriteLine tcp,"Content-Length: " + ( Len( Content ) +2 ) WriteLine tcp,"" WriteLine tcp,Content ;Hier wird aus gelesen was vom Server kommt While Not KeyDown(1) If ReadAvail( tcp ) DebugLog ReadLine(tcp) EndIf Wend CloseTCPStream tcp End Der Fehler war, dass Boundary mit "--" eingeleitet wird. Wenn man also Boundary als "blubb" definiert, dann muss es später "--blubb" sein. Und da sowohl MSIE und auch Firefox den Boundary schon "----------------------------------blablabla" definieren, fiel mir das gar nicht auf, dass da plötzlich noch zwei - vorne angehängt wurden ![]() mfG |
||
Erledige alles Schritt um Schritt - erledige alles. - Holzchopf
CC BY ♫ BinaryBorn - Yogurt ♫ (31.10.2018) Im Kopf da knackt's und knistert's sturm - 's ist kein Gedanke, nur ein Wurm |
Appart |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Vielen Dank jetzt geht es ohne Probleme =)
MFG Appart |
||
tmode00Betreff: Vielen Dank! |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hallo,
ich möchte mich an dieser Stelle ganz recht herzlich bedanken. Ohne diesen Thread hätte ich das mit dem Fileupload per BB / Php nie hinbekommen. Echt stark ![]() |
||
While (1) : Wend |
![]() |
Pummelie |
![]() Antworten mit Zitat ![]() |
---|---|---|
zum danken hätte auch ein pm gereicht, statt diese "leiche" wieder aus zu buddeln | ||
It's done when it's done. |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group