I program in C# that uploads the file contents to a directory within the website folder.The Server.MapPath method stores the file to the folder Upload which is a part of the website. If there is a server can I upload the files there by giving the IP and the location such as "137.2.42.244/Documents". The server OS is a Solaris.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace FileUpLoadMVC.Controllers
{
public class FileUploadController : Controller
{
// GET: FileUpload
public ActionResult Index()
{
return View();
}
[HttpPost]
public void UploadFiles()
{
if (Request.Files?.Count > 0)
{
var filesCount = Request.Files.Count;
for (int i = 0; i < filesCount; i++)
{
var file = Request.Files[i];
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Upload"), fileName);
file.SaveAs(path);
}
}
}
}
}