Provide a aspx web form to upload a file to an FTP server folder & and create a new folder if one doesn't exist RRS feed

  • Question

  • User676121591 posted


    I have been asked to provide a web form that allows a user to upload a csv/xlsx file to a secure FTP folder.  Also, we need to be able to use the Senders email address as the sub folder (if it doesnt already exist) and place the file in there.

    Can anyone let me know how to get started?  I have installed VS2019 Community Edition and raring to go!

    Many thanks,


    Thursday, June 6, 2019 3:47 PM

All replies

  • User475983607 posted

    File upload using a browser is HTTP not FTP.  Your web application either needs access to the FTP folder assuming the folder is on the same machine as the web app or you need to write code using the .NET FTP library to FTP the file after uploading to your web server.

    ASPX File Upload


    Thursday, June 6, 2019 4:18 PM
  • User61956409 posted

    Hi Fiorano,

    If you'd like to implement functionality of saving file on your server that is hosting your web application, you can refer to the link that mgebhard shared to use FileUpload control.

    Besides, if you'd like to save the user uploaded file(s) in your another FTP server, you can refer to the following code snippet.

    FtpWebRequest request = (FtpWebRequest)WebRequest.Create($"ftp://xxxxx/user/{filename}");
    request.Method = WebRequestMethods.Ftp.UploadFile;
    request.Credentials = new NetworkCredential(@"userName_here", "userPWD_here");
    using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
    using (Stream requestStream = request.GetRequestStream())

    To creates a directory on an FTP server, you can use MakeDirectory.


    With Regards,

    Fei Han

    Friday, June 7, 2019 6:02 AM