Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends

thanks in advance... :)

I want to upload a image file on my ftp using a file upload control in asp .net but i don't know how to upload & download files on ftp using c# code...

Heml me.....
Posted

1 solution

You don't use a file upload control on FTP: FTP has no UI element, it is all command based, and thus cannot even display the controls.


"actually i'm making a site in which Client want to upload a file from his system or anywhere but the file does not store in database has to be saved on his hosting space.

Tell me what is the problem of this solution...??"



You don't need FTP for that: just add an upload control to your page, and handle the Upload Click event:

C#
/// <summary>
/// Upload the file to the database.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void butUpload_Click(object sender, EventArgs e)
    {
    StatusLabel.Text = SaveUpload(FileUpload1);
    }
/// <summary>
/// Save an upload into the database.
/// </summary>
/// <param name="fl">Control containing the download.</param>
/// <returns>Status as a string</returns>
private string SaveUpload(FileUpload fl)
    {
    if (fl.HasFile)
        {
        try
            {
            int version = 0;
            string filename = Path.GetFileName(fl.FileName);
            byte[] filedata = fl.FileBytes;
(The rest of this is irrelevant to you, as it saves to a DB, with version control)
Once you have these two bits of info, you can save it where you need to on his web host.
 
Share this answer
 
v2
Comments
devildx2050 27-Sep-11 14:27pm    
actually i'm making a site in which Client want to upload a file from his system or anywhere but the file does not store in database has to be saved on his hosting space.

Tell me what is the problem of this solution...??
OriginalGriff 27-Sep-11 14:38pm    
Answer updated

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900