59FIFTY Posted January 19, 2007 Share Posted January 19, 2007 I have a little problem creating file from a mime content. The browser transmits a little 10x10bmp file like thisBMv0x00000x00000x00000x36000x00000x28000x00000x0A000x00000x0A000x00000x01000x18000x00000x0000@0x00 000x00000x00000x00000x00000x00000x00000x00000x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x00 00ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿ0x0000 if I try to create this file by using FileWrite it totally fails and creates a 510byte image (size should be 374byte). After that I opened the existing file with FileOpen and the console output returns me thisBMv any ideas how to create the file above correctly? Link to comment Share on other sites More sharing options...
59FIFTY Posted January 19, 2007 Author Share Posted January 19, 2007 Can't fix it and I'm stuck Link to comment Share on other sites More sharing options...
Joon Posted January 19, 2007 Share Posted January 19, 2007 I don't know well enough to answer your question. But I do know you can't just copy content and create file. What you see there is encode text, you have to decode it. Link to comment Share on other sites More sharing options...
59FIFTY Posted January 19, 2007 Author Share Posted January 19, 2007 I dont copy it, I get it directly from the socket input, the result you see above is when I output the file sent by the browser with ConsoleWrite, I was wondering what's the difference between the file sent from the browser, and the file opened by autoit. The image comes already in BinaryString. I have absolutly no idea how to create that simpel image from the code :\ Link to comment Share on other sites More sharing options...
Joon Posted January 19, 2007 Share Posted January 19, 2007 MIME contains heading... Something like belowContent-type: message/external-body; access-type=local-file; name="/u/nsb/Me.gif" Content-type: image/gifContent-ID: Content-Transfer-Encoding: binaryMost browser know how to deal appropriately depends on the MIME type. Not sure how autoit handling it. Link to comment Share on other sites More sharing options...
59FIFTY Posted January 19, 2007 Author Share Posted January 19, 2007 The MIME Header is parsed correctly, it's inside a multipart form-data split by a regular boundary, the problem is to create the file itself. I have the image as a binary string but I ant create the file by using FileOpen. Content-Disposition: form-data; name="bmpFile"; filename="10x10px.bmp" Content-Type: image/bmp BMv0x00000x00000x00000x36000x00000x28000x00000x0A000x00000x0A000x00000x01000x18000x00000x0000@0x00 000x00000x00000x00000x00000x00000x00000x00000x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x00 00ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿ0x0000 The head is split correctly from the data part, and the data part doesn't contain any CRLF at the left or right side, so why can'it I create the image by simply using $fp = FileOpen("file.bmp", 2) FileWrite($fp, $binaryString) ;string from above FileClose($fp) Link to comment Share on other sites More sharing options...
Joon Posted January 19, 2007 Share Posted January 19, 2007 You should have Content-Transfer-Encoding heading. Just as it said, it is encoded text string. This needs to be decode then write to a File. Link to comment Share on other sites More sharing options...
59FIFTY Posted January 19, 2007 Author Share Posted January 19, 2007 You misunderstand me, this is the head & data sent by the browser and decoded by my script, and as you clearly could see, there is no transfer-encoding since it isn't encoded, it's a simple binary string (the same if you output a image to a server). Here is the full attached browser request.POST / HTTP/1.1 Host: 127.0.0.1:8080 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 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://www.11notes.com/post.html Content-Type: multipart/form-data; boundary=---------------------------5043137917953 Content-Length: 773 -----------------------------5043137917953 Content-Disposition: form-data; name="formVar1" variable1 -----------------------------5043137917953 Content-Disposition: form-data; name="formVar2" variable2 -----------------------------5043137917953 Content-Disposition: form-data; name="bmpFile"; filename="10x10px.bmp" Content-Type: image/bmp BMv0x00000x00000x00000x36000x00000x28000x00000x0A000x00000x0A000x00000x01000x18000x00000x0000@0x00 000x00000x00000x00000x00000x00000x00000x00000x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x00 00ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0x0000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿ0x0000 -----------------------------5043137917953-- Link to comment Share on other sites More sharing options...
59FIFTY Posted January 20, 2007 Author Share Posted January 20, 2007 still can't get it to work and I'm gona loose it Link to comment Share on other sites More sharing options...
59FIFTY Posted January 20, 2007 Author Share Posted January 20, 2007 bump Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now