How to program to upload / send an image to an image hosting site without a browser?

I want to write a simple utility to upload images to various free image hosting sites like TinyPic or Imageshack using the context menu of the context menu for the file.

How can I do this using .NET? I have seen some linux scripts that use cURL to host images on this website, but I'm not sure how to create a post request with an image in C #?

Can anyone point me in the right direction?


I found a pretty good resource. Cropper, a free screenshot tool written in .net, has many open source plugins. One of them is SendToTinyPic .. complete with source. Link here:


source to share

4 answers

The FlickrNet API makes it extremely easy to work with Flickr from within .NET. You must have a Flickr account and an API key and shared secret . Once you have what you need, working with the API is very simple:

string flickrApiKey = "<api key>";
string flickrApiSharedSecret = "<shared secret>";
string flickrAuthenticationToken = "<authentication token>";

Flickr flickr = new Flickr( flickrApiKey, flickrApiSharedSecret );

flickr.AuthToken = flickrAuthenticationToken;    

foreach ( FileInfo image in new FileInfo[] { 
    new FileInfo( @"C:\image1.jpg" ), 
    new FileInfo( @"C:\image2.jpg" ) } )
    string photoId = flickr.UploadPicture(
        image.FullName, image.Name, image.Name, "tag1, tag2" );




Use HttpWebRequest.

Using this class, you can send POST data to remote HTTP address, just set mime / type to multi-part / form encoding and send binary data from image with request.



For ImageShack, take a look at this app .


source does not have an API as far as I know, but the Cropper SendToTinyPic plugin is trying to load with Screen Scraper. "The official version of the plugin is not working right now, but I put together a patch using the same approach and submitted it to the cropperplugins project . This is just one original module that changed, anyone can download the plugins project and then go to my patch and it should work.

Using the patch PritScrn or Alt-PrntScrn will save the image and load into TinyPic and add the URL of the raw image to the clipboard. Everything in 2 seconds. easy.

If you don't need a real tool, you can still look at the source code of my patch to see how to POST a page with form data and upload a file. There is no direct link. See and look for # 3239.

This sample image was created and then automatically uploaded to using the Alt-PrtScrn keyboard shortcut. Sample image

To enable it here, I just needed ctrl-V because the url is stored in the clipboard.



All Articles