Sending an Image over HTTP.
-
Here's a puzzle. I intend to send an image (jpeg) to a PHP-Driven website via HTTP POST, using a C# app compiled for the .NET Compact Framework. So far Its all working apart from one thing, when sending the file, it is created on the server, but is corrupt. I'm positive this is down to the image not being sent in the correct format, but what format is it supposed to be sent? The method of sending is using a WebRequest object and its RequestStream. Method = "POST"; ContentType = "multipart/form-data; boundary=AaB03x"; The following HTTP post is sent through the stream.
--AaB03x
Content-Disposition: form-data; name="title"
Content-Type: text/plain; charset=utf-8Title
--AaB03x
Content-Disposition: attachment; name="file" filename="nexi0001.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binarycontents of file...
--AaB03x--Now alls I need to do is send the image data with this. Yet I've no idea in what format to send it and thus how to prepare this format on the CF. Ideas?
Jonathan 'nonny' Newman blog.nonny.com [^]
-
Here's a puzzle. I intend to send an image (jpeg) to a PHP-Driven website via HTTP POST, using a C# app compiled for the .NET Compact Framework. So far Its all working apart from one thing, when sending the file, it is created on the server, but is corrupt. I'm positive this is down to the image not being sent in the correct format, but what format is it supposed to be sent? The method of sending is using a WebRequest object and its RequestStream. Method = "POST"; ContentType = "multipart/form-data; boundary=AaB03x"; The following HTTP post is sent through the stream.
--AaB03x
Content-Disposition: form-data; name="title"
Content-Type: text/plain; charset=utf-8Title
--AaB03x
Content-Disposition: attachment; name="file" filename="nexi0001.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binarycontents of file...
--AaB03x--Now alls I need to do is send the image data with this. Yet I've no idea in what format to send it and thus how to prepare this format on the CF. Ideas?
Jonathan 'nonny' Newman blog.nonny.com [^]
-
I think you have to send it in Base64 format. For the beginning check
ToBase64Transform
class. Mazy "Improvisation is the touchstone of wit." - MolièreI can't seem to be able to use that class in the Compact Framework, would Convert.ToBase64CharArray() work do you think?
Jonathan 'nonny' Newman blog.nonny.com [^]
-
I can't seem to be able to use that class in the Compact Framework, would Convert.ToBase64CharArray() work do you think?
Jonathan 'nonny' Newman blog.nonny.com [^]
-
Here's a puzzle. I intend to send an image (jpeg) to a PHP-Driven website via HTTP POST, using a C# app compiled for the .NET Compact Framework. So far Its all working apart from one thing, when sending the file, it is created on the server, but is corrupt. I'm positive this is down to the image not being sent in the correct format, but what format is it supposed to be sent? The method of sending is using a WebRequest object and its RequestStream. Method = "POST"; ContentType = "multipart/form-data; boundary=AaB03x"; The following HTTP post is sent through the stream.
--AaB03x
Content-Disposition: form-data; name="title"
Content-Type: text/plain; charset=utf-8Title
--AaB03x
Content-Disposition: attachment; name="file" filename="nexi0001.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binarycontents of file...
--AaB03x--Now alls I need to do is send the image data with this. Yet I've no idea in what format to send it and thus how to prepare this format on the CF. Ideas?
Jonathan 'nonny' Newman blog.nonny.com [^]
Is System.Net.WebClient.UploadFile method available in CF?