Jump to content

Recommended Posts

Posted

I have a little problem creating file from a mime content. The browser transmits a little 10x10bmp file like this

BMv0x00000x00000x00000x36000x00000x28000x00000x0A000x00000x0A000x00000x01000x18000x00000x0000@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 this

BMv

any ideas how to create the file above correctly?

Posted

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.

Posted

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 :\

Posted

MIME contains heading... Something like below

Content-type: message/external-body;

access-type=local-file;

name="/u/nsb/Me.gif"

Content-type: image/gif

Content-ID:

Content-Transfer-Encoding: binary

Most browser know how to deal appropriately depends on the MIME type. Not sure how autoit handling it.

Posted

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)
Posted

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.

Posted

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--

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...