[英]How to use javascript to show “Open File Dialog” or “Save File Dialog” and get full path both?
[英]Open dialog box and Get file path in MVC
我是MVC的初學者。 我有一個不尋常的情況。我已經使用剃刀將Windows項目轉換為MVC Web應用程序。
我需要的是單擊按鈕並打開對話框,然后單擊“獲取從對話框到文本框的文件路徑”,例如C:\\ user \\ Accentra \\ Desktop \\ durai
謝謝提前
杜萊
不知道你的意思在這里。 您是指文件上傳,因此用戶按下按鈕,選擇文件,然后將其保存到服務器? 如果是這樣的話...
您可以說,文件上傳控制是指用戶何時可以上傳文件-在POST上,該值將被發布到您,然后在保存到服務器時您需要執行的操作。
例:
public ActionResult Index(HttpPostedFileBase file) {
if (file.ContentLength > 0) {
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
file.SaveAs(path);
}
return RedirectToAction("Index");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.