我正在尝试将文件上传到远程服务器。我在本地服务器(机器A)上有这个MVC5站点,文件应该转到另一台服务器(机器B)。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "Id,Email,FirstName,LastName,DOB,Gender,AutoLogin,Password,ScreenName,NotificationsOn,ThumbnailURL")] User user, IEnumerable<HttpPostedFileBase> files)
{
HttpPostedFileBase photo = Request.Files[0];
if (photo != null)
{
//do some stuff with the file, like limit size and extensions
//smp = localhost folder (machine A) and I need the remote folder(machine B).
//How do I do this? If I need FTP, how to connect?
string smp = Server.MapPath("~/UserContent/");
photo.SaveAs(smp" + photo.FileName);
}
if (ModelState.IsValid)
{
db.Users.Add(user);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(user);
}