处理上传文件控件碰到的问题

Request.Files["file2"].FileName


IE启动时,取得的是文件的全路径,谷歌启动时,取得的是文件的单文件名

以后处理这类问题时,需要多浏览器debug.


另:记录一下代码,需求就是去除默认上传文件控件的外形,只留一个按钮,同时后面文本框显示当前文件名.

                        <tr>
                            <td>
                                <span class="inputfile">文件选择
                                    <input type="file" id="file1" name="file1" value="file1"  οnchange="setFileName('file1','fileNameTextBox1')" />
                                </span>
                            </td>
                            <td>①</td>
                            <td>@Html.TextBoxFor(m => m.UploadFileName1, new { style = "width: 400px; text-align: left", id = "fileNameTextBox1" })</td>
                            <td><input type="submit" value="上传" name="File1Upload" style="width: 100px;" @Model.DisableEvidenceButton() /></td>
                            <td><input type="button" id="dlFile1" value="DL" title="DL" style="width: 50px;" οnclick="parent.location='@Url.Action("EvidenceDownload", "WorkFlowConfirmPortal", new { ApplyId = Model.ApplyId, CustomerID = Model.CustomerID, IsApprovalMode = Model.IsApprovalMode, IsFromReadAllPage = Model.IsFromReadAllPage, FolderName = "1" })    '" /><td>
                            <td><input type="button" id="deleteFile1" value="删除" title="删除" style="width: 50px;" @Model.DisableEvidenceButton()  οnclick="parent.location='@Url.Action("EvidenceDelete", "WorkFlowConfirmPortal", new { ApplyId = Model.ApplyId, CustomerID = Model.CustomerID, IsApprovalMode = Model.IsApprovalMode, IsFromReadAllPage = Model.IsFromReadAllPage, FolderName = "1" })    '" /><td>
                        </tr>

JS:

function setFileName(fileId, fileNameText)
{
        var file = $('#' + fileId).val().split('\\');
    var fileName = file[file.length - 1];

    $('#' + fileNameText).val(fileName);
}
css

.inputfile {
    position: relative;
    display: inline-block;
    background: #F0F0F0;
    border: 1px solid #6C6C6C;
    border-radius: 4px;
    padding: 4px 16px;
    overflow: hidden;
    color: #272727;
    text-decoration: none;
    text-indent: 0;
    line-height: 12px;
	margin-top: 3px;
}
.inputfile input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
	filter: alpha(opacity=0);
}
.inputfile:hover {
    background: #F0F0F0;
    border-color: #6C6C6C;
    color: #272727;
    text-decoration: none;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值