I was wondering what the best library is for uploading an image to like imageshack or something? mabey a tutorial would be nice too lol

Recommended Answers

All 5 Replies

i think that is an ASP.NET question.

http://forums.asp.net/p/1447734/3296632.aspx

# 1    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageHandling.aspx.cs" Inherits="ProcessMonitoring" %>  
# 2      
# 3    "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
# 4      
# 5    <html xmlns="http://www.w3.org/1999/xhtml" >  
# 6    "server">  
# 7        Untitled Page  
# 8    9    "linen">  
# 10       "form1" runat="server">  
# 11         
# 12 13 14 16 18 19 20 22 23 24 27 28 29 31 32 33 35 36  
# "width: 100px"> 15 "Label1" runat="server">   "width: 100px"> 17 "Label2" runat="server">  
# "2"> 21  "TextBox1" runat="server">  
# "2"> 25 "imgUpload" runat="server" /> 26  
# "2"> 30 "Button1" runat="server" Text="Button" Width="120px" OnClick="Button1_Click" />  
# "2"> 34 "Image1" runat="server" OnDisposed="Button1_Click" />  
# 37   38 39  
#   
# 40              
# 41         
# 42   43   44     
#   
#    
#   
#  /*************************************aspx.cs file*********************************/  
#   
#     
#   
# 1    using System;  
# 2    using System.Data;  
# 3    using System.Configuration;  
# 4    using System.Collections;  
# 5    using System.Web;  
# 6    using System.Web.Security;  
# 7    using System.Web.UI;  
# 8    using System.Web.UI.WebControls;  
# 9    using System.Web.UI.WebControls.WebParts;  
# 10   using System.Web.UI.HtmlControls;  
# 11   using System.Data.SqlClient;  
# 12   using System.Diagnostics;  
# 13   using System.Runtime.Remoting;  
# 14     
# 15     
# 16   public partial class ProcessMonitoring : System.Web.UI.Page  
# 17   {  
# 18       SqlConnection connection;  
# 19       protected void Page_Load(object sender, EventArgs e)  
# 20       {  
# 21           Image1.Visible = false;     
# 22                    
# 23       }  
# 24         
# 25       protected void Button1_Click(object sender, EventArgs e)  
# 26       {  
# 27             
# 28           try  
# 29           {  
# 30               FileUpload img = (FileUpload)imgUpload;  
# 31               Byte[] imgByte = null;  
# 32               if (img.HasFile && img.PostedFile != null)  
# 33               {  
# 34                   //To create a PostedFile  
# 35                   HttpPostedFile File = imgUpload.PostedFile;  
# 36                   //Create byte Array with file len  
# 37                   imgByte = new Byte[File.ContentLength];  
# 38                   //force the control to load data in array  
# 39                   File.InputStream.Read(imgByte, 0, File.ContentLength);  
# 40               }  
# 41               // Insert the employee name and image into db  
# 42             string conn = ConfigurationManager.ConnectionStrings["EmployeeConnString"].ConnectionString;  
# 43               connection = new SqlConnection(conn);  
# 44               connection.Open();  
# 45               //string sql = "INSERT INTO temp_screen(e_name,images) VALUES(@enm, @eimg) SELECT @@IDENTITY";  
# 46               SqlCommand cmd = new SqlCommand("INSERT INTO temp_screen(e_name,images) VALUES(@enm, @eimg) SELECT @@IDENTITY", connection);  
# 47               cmd.Parameters.AddWithValue("@enm", TextBox1.Text.Trim());  
# 48               cmd.Parameters.AddWithValue("@eimg", imgByte);  
# 49               int id = Convert.ToInt32(cmd.ExecuteScalar());  
# 50               Label1.Text = String.Format("Employee ID is {0}", id);  
# 51     
# 52               // Display the image from the database  
# 53               Image1.Visible = true;  
# 54               Image1.ImageUrl = "~/ShowImage.ashx?id=" + id;  
# 55               string ter = null;  
# 56           }  
# 57           catch(Exception ex)  
# 58           {  
# 59               Label2.Text = "There was an error";  
# 60               Response.Write(ex.Message);  
# 61           }  
# 62           finally  
# 63           {  
# 64               connection.Close();  
# 65           }  
# 66     
# 67       }  
# 68   }  
# 69

Dude there is a seperate forum for such questions.
This thread must be moved to ASP.NET forum

His question is really a C# question. You would need to use a WebClient or WebBrowser control to upload the images. You need to login (authenticate) and navigate to the upload URL and submit the image. Unfortunately this is a rather difficult task so i'm not sure. Make sure you have cookies enabled on whatever client you decide to move forward with.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.