Click here to Skip to main content
14,639,661 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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:

/// <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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100