我在我的mvc项目中使用<input type="file" id="fileId" name="fileId"/>和<% = Html.TextBoxFor (x => x.FileName, new {@ class = "className", maxlength = 255, id = "fileName"})%>。我想要在文本框中保存在输入元素中选择的文件名。我该怎么做呢?
发布于 2010-12-08 15:56:31
你需要使用javascript来实现这一点。下面是一个使用jquery的示例:
$(function() {
$('#fileId').change(function() {
// When the user selects a file, read the selected filename
// and set it to the textbox
var filename = $(this).val();
$('#fileName').val(filename);
});
});https://stackoverflow.com/questions/4385191
复制相似问题