473,320 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Posting binary / image files

Hi

I'm trying to post an image using the Web Browser control:

object oURL="http://www.somedomain.com/test.php"; //form processing

cPostData = @"userfile=C:\\avatar.jpg";
vHeaders = "Content-Type: multipart/form-data" + "\n" + "\r";

vPost = ASCIIEncoding.ASCII.GetBytes(cPostData);

axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref vPost, ref vHeaders);

Of course it doesn't work. What must I do to correctly load up the image to be posted, as happens when using the <input Type='file' .... browse box?

In addition if anone knows how to do the same thing using HttpWebRequest, that would be helpful too.

Thanks
Magnus
Jul 21 '05 #1
4 1666
Try the WebClient.UploadFile() method. Also, if you're just itching to build the form yourself, take a look at http://www.ietf.org/rfc/rfc1867.txt

"Magnus" wrote:
Hi

I'm trying to post an image using the Web Browser control:

object oURL="http://www.somedomain.com/test.php"; //form processing

cPostData = @"userfile=C:\\avatar.jpg";
vHeaders = "Content-Type: multipart/form-data" + "\n" + "\r";

vPost = ASCIIEncoding.ASCII.GetBytes(cPostData);

axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref vPost, ref vHeaders);

Of course it doesn't work. What must I do to correctly load up the image to be posted, as happens when using the <input Type='file' .... browse box?

In addition if anone knows how to do the same thing using HttpWebRequest, that would be helpful too.

Thanks
Magnus

Jul 21 '05 #2
Thanks Todd, I'm trying this but still no success yet. I saw by your other post you're interested in something similar. If you find any interesting examples I'd be grateful if you could post a link here and I will check back every so often.

Thanks
Magnus

"Todd Bright" wrote:
Try the WebClient.UploadFile() method. Also, if you're just itching to build the form yourself, take a look at http://www.ietf.org/rfc/rfc1867.txt

"Magnus" wrote:
Hi

I'm trying to post an image using the Web Browser control:

object oURL="http://www.somedomain.com/test.php"; //form processing

cPostData = @"userfile=C:\\avatar.jpg";
vHeaders = "Content-Type: multipart/form-data" + "\n" + "\r";

vPost = ASCIIEncoding.ASCII.GetBytes(cPostData);

axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref vPost, ref vHeaders);

Of course it doesn't work. What must I do to correctly load up the image to be posted, as happens when using the <input Type='file' .... browse box?

In addition if anone knows how to do the same thing using HttpWebRequest, that would be helpful too.

Thanks
Magnus

Jul 21 '05 #3
Thanks Todd, I'm trying this but still no success yet. I saw by your other post you're interested in something similar. If you find any interesting examples I'd be grateful if you could post a link here and I will check back every so often.

Thanks
Magnus

"Todd Bright" wrote:
Try the WebClient.UploadFile() method. Also, if you're just itching to build the form yourself, take a look at http://www.ietf.org/rfc/rfc1867.txt

"Magnus" wrote:
Hi

I'm trying to post an image using the Web Browser control:

object oURL="http://www.somedomain.com/test.php"; //form processing

cPostData = @"userfile=C:\\avatar.jpg";
vHeaders = "Content-Type: multipart/form-data" + "\n" + "\r";

vPost = ASCIIEncoding.ASCII.GetBytes(cPostData);

axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref vPost, ref vHeaders);

Of course it doesn't work. What must I do to correctly load up the image to be posted, as happens when using the <input Type='file' .... browse box?

In addition if anone knows how to do the same thing using HttpWebRequest, that would be helpful too.

Thanks
Magnus

Jul 21 '05 #4
Thanks Todd, I'm trying this but still no success yet. I saw by your other post you're interested in something similar. If you find any interesting examples I'd be grateful if you could post a link here and I will check back every so often.

Thanks
Magnus

"Todd Bright" wrote:
Try the WebClient.UploadFile() method. Also, if you're just itching to build the form yourself, take a look at http://www.ietf.org/rfc/rfc1867.txt

"Magnus" wrote:
Hi

I'm trying to post an image using the Web Browser control:

object oURL="http://www.somedomain.com/test.php"; //form processing

cPostData = @"userfile=C:\\avatar.jpg";
vHeaders = "Content-Type: multipart/form-data" + "\n" + "\r";

vPost = ASCIIEncoding.ASCII.GetBytes(cPostData);

axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref vPost, ref vHeaders);

Of course it doesn't work. What must I do to correctly load up the image to be posted, as happens when using the <input Type='file' .... browse box?

In addition if anone knows how to do the same thing using HttpWebRequest, that would be helpful too.

Thanks
Magnus

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Albert Tu | last post by:
Hi, I am learning and pretty new to Python and I hope your guys can give me a quick start. I have an about 1G-byte binary file from a flat panel x-ray detector; I know at the beggining there...
9
by: Maurizio Penna | last post by:
I, guys. I've embeded an image into a xml file, something like that: <display type="picture" mime="image/png" name = "mosaico6.png"> <!]> </display> Now, I want to display it with a XSL...
27
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there...
1
by: bjarthur | last post by:
i have (see below) what i think is a fairly simple algorithm, but yet it doesn't work. given a directory with consecutively numbered jpeg files (1.jpg, 2.jpg, 3.jpg...), it is designed to count...
3
by: Josema | last post by:
Hi to all, I have stored in a database some binary files (pdfs, and gif images), i would like to know how could i show it, in internet explorer when a person enters for instance in a textbox the...
2
by: S.Creek | last post by:
Hi, I need to take few files (images in my case) and create one file out of them, this file should be accessed so i can grab a single image from it if necessary, i thought of taking all the...
4
by: Alex Vincent | last post by:
HI all, I'm storing images, jpgs/gifs/png/bmps and also some other binary files in a SQL image field in a SQL 2k database. Most of the images enter the database via a asp.net webform upload,...
4
by: Beginner | last post by:
How do I convert JPEG images to binary files in ASP.NET? Please advice. Thanks.
3
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its...
16
by: Erwin Moller | last post by:
Why is a binary file executable? Is any binary file executable? Is only binary file executable? Are all executable files binary? What is the connection between the attribute of binary and that of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.