Upload files to a remote server

前端 未结 3 1312
梦如初夏
梦如初夏 2021-01-15 05:27

I need to upload files from my asp.net (C#) page residing in the web server to a remote server.

I managed to upload files to remote server from localhost using this

3条回答
  •  清酒与你
    2021-01-15 05:33

    In FileUpload1.PostedFile.SaveAs(path), path is physical path of file, No Url. You must check:

    • is Physical folder Exsist?
    • is You have access to folder?

    if answer of both question is true check this code:

    string serverPath = @"\\xxx.xxx.xxx.xxx\Folder\";
    if (!System.IO.Directory.Exists(serverPath))
        System.IO.Directory.CreateDirectory(serverPath);
    
    FileUpload1.PostedFile.SaveAs(serverPath + FileUpload1.FileName);
    

提交回复
热议问题