Simple ImageShack upload using C#

Filed Under (c#) by The Chef on 08-06-2009

Tagged Under : , , ,

First of all this class is based on the http helper class. The rest is trivial. Here is a piece of code

    public static class ImageShack
    {
        private static http http = new http();

        public static String UploadImage(String filename)
        {
            http.PostMode = PostMode.Multipart;
            http.AddPostKey("xml", "yes");
            http.AddPostFile("fileupload", filename);
            return http.GetUrl("http://www.imageshack.us/index.php");
        }
    }

The result is an xml. You can deserialize it using the XML serializer/deserializer from the previous post.

    [Serializable]
    public class links
    {
        public String image_link;
        public String thumb_link;
        public String ad_link;
        public String thumb_exists;
        public int total_raters;
        public float ave_rating;
        public String server;
        public String image_name;
        public String done_page;
        public String resolution;
        public int filesize;
        public String image_class;
    }

.
.
.
imageshark isr=new imageshark();
links lnk = new links();
lnk = XMLData.ObjectXMLSerializer<links>.LoadString(ImageShack.UploadImage("picture.png"));
Console.WriteLine(lnk.image_link);

Hope it helps. Enjoy

Comments:

3 Responses to “Simple ImageShack upload using C#”


  1. Yes, the answer almost same, as well as at me.


  2. Thanks for the useful info. It’s so interesting


  3. I wrote an ImageShack uploader library/demo application in C# a few months back but only just got around to making a post about it here – [link]. There’s source code available for both the library and the demo app, as well as compiled copies of both. Hope someone finds this useful. Cheers, Bryce.

Leave a Reply