gpt4 book ai didi

c# - MVC : How to get full file path from file input field?

转载 作者:行者123 更新时间:2023-11-30 20:33:08 26 4
gpt4 key购买 nike

<分区>

我有以下 Razor 代码:

  <div class="container">
@Html.ValidationSummary(false)
@using (Html.BeginForm("EncryptFile", "Encryption", new { returnUrl = Request.Url.AbsoluteUri }, FormMethod.Post, new { @id = "encryptionform", @class = "form-horizontal" }))
{

<div class="form-group">
@Html.Label("File", new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="file" id="encryptfilefield" name="uploadedfile" enctype='multipart/form-data'/>
</div>
</div>


<button type="submit" id="encryptfilebutton">Encrypt</button>
<button id="decryptfilebutton" type="button">Decrypt</button>
<button id="reencryptfilebutton" type="button">Re-Encrypt</button>

}
</div>

当我单击“加密”按钮时将调用以下 Controller 代码:

  [HttpPost]
public ActionResult EncryptFile(string uploadedfile)
{
/*process the file without uploading*/
return Json(new { status = "success", message = "Encrypted!" });
}

当我点击加密按钮时,我能够点击这个 Action ,但是 uploadedfile 字符串总是以 null 的形式出现。如何获取所选文件的填充文件路径?请注意,我并不是要将其上传到服务器(尽管名称中出现“已上传”),我只需要文件路径。

编辑

我在 IE 11 中看到以下内容完整显示了文件路径(警报内的部分):

alert($("#encryptfilefield").val());

但这不是一个完整的解决方案,而且由于它是一个安全问题,因此似乎没有解决方案。谢谢。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com