views:

549

answers:

3

Hello, I am working on a mobile application on .net. This is a windows mobile application. I am facing a problem in this application that I wanna upload an image/file to given url/server. Many upload classes is not using like Webclient,WebRequest,WebResponse. I used HttpWebRequest, That is not connecting with server. Pls anyone help me on how to upload the images on given url in windows mobile 6 in .net.

Thanks in advance.

Pankaj

A: 

Not sure what you mean exactly with uploading images to a given URL. Surely you need some listener or something on your server to be able to receive the image data.

You could create a .NET web service, with a function that takes a byte[] input parameter to upload your image data, on your server and reference that in your Windows Mobile application.

tomlog
A: 

Can you modify the server code as well? If so there are a couple of other options.

You could store the images in a database (SQL Server Compact Edition) and then use Synchronization Services.

You could use WCF to transfer the data (for mobile you have two WCF options, web service and message...you might want message for this).

Chris Brandsma
A: 

The target server should have a web page that excepts the image when it shows up. Open a file stream, load the image into memory in a byte buffer. Use the fileinfo to get the details such as length, you will need that later. Open a binary reader, and read the image into the buffer. Open a WebRequest.Create with your URL, set method to post, nice long timeout, request.content length to the length of the byte buffer, open an instance of a stream to your instance of the request.GetRequestStream(). like so.. create a binary writer using the stream, write the filebuffer, close em, open the web response, start a stream reader to GetResponseStream and check the bytes received match what you sent. I found nice code on EggheadCafe under data transfer.