Reputation: 31
How to upload files from ASP.NET web application to any web server(linux)..
Upvotes: 0
Views: 674
Reputation: 100567
Take these steps as a general guideline:
SaveAs
path be a UNC path to a share on the remote server.Here's more on the FileUpload ASP.NET Server Control at MSDN.
<asp:FileUpload ID="FileUpload1" runat="server" />
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(@"\\server2\SomeShare\" + FileUpload1.FileName);
}
If you wanted the files to be saved first on your ASP.NET box:
c:\uploads\temp
or what-have-youSystem.IO.File.Move
string[] files = System.IO.Directory.GetFiles(@"c:\uploads\temp");
foreach (string s in files)
{
string fileName = System.IO.Path.GetFileName(s);
string destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile);
}
Upvotes: 1
Reputation: 218827
If the Linux server in question exposes an FTP service, then here's a tutorial for accessing that in .NET. If FTP is not an option, then please specify what service the Linux server is exposing for file upload (Samba, NFS, etc.).
Upvotes: 0