Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Upload image to ftp with file uploader using asp.net 2.0.

Author: Zunnair
Download Source Code : 898_ImageUploader.zip

In this simple article you will learn to upload image to ftp using file uploader.

 Create a web application in c#.

Drag a button, one label and one file uploader on the form
Then write code on form load event
 
C#
protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "Select Image";
        Button1.Text ="Upload to FTP";
    }
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Label1.Text = "Select Image"
        Button1.Text = "Upload to FTP"
    End Sub
After that write some code on button click even
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        string ServerMapPath = Server.MapPath("~//images//Image1.jpg");
        FileUpload1.PostedFile.SaveAs(ServerMapPath);
    }
VB
 protected void Button1_Click(object sender, EventArgs e)
    {
        string ServerMapPath = Server.MapPath("~//images//Image1.jpg");
        FileUpload1.PostedFile.SaveAs(ServerMapPath);
    }
 
This is simple code to upload image to ftp using file uploader.
 
Article Comments
It's very very good Example you have given here to upload image. But Please tell me how to view that uploaded image in the panel or any other, onthe click of button.
I can't get proper and simple solution till now.Please help..

Thank you..

Posted on 7/13/2010 9:44:53 AM by Chetan R.Pande,Nagpur

You can use Linq query and bind its query result to GridView name "gvImages" when any body click on the button

It is as follows

Dim AllImages As New List(Of IO.FileInfo)

Try
Dim di As New IO.DirectoryInfo("~//images//")
AllImages.AddRange(di.GetFiles("*.*", IO.SearchOption.AllDirectories))

Catch ex As Exception

'Error Message

End Try

Dim FileQuery = From FI In AllImages _
Order By FI.LastWriteTime Descending _
Select FI.LastWriteTime, FI.Name, FI.FullName

Me.gvImages.DataSource = FileQuery
Me.gvImages.DataBind()

Posted on 8/25/2010 9:22:34 AM by jojo lili

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Access Html Div Control in code behind using asp.net 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net