You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
$(document).ready(function () {
|
|
$(document).off('click',sendFile).on('click','.upload-it',sendFile);
|
|
$(document).off('click',selectFile).on('click','.select-file',selectFile);
|
|
$(document).off('change',showMsg).on('change','.true-select',showMsg)
|
|
})
|
|
function sendFile() {
|
|
var fileData =new FormData;
|
|
var Url4='testfrom.jsp';
|
|
var file=$('.true-select').files;
|
|
if($('.true-select').val()=='')
|
|
{
|
|
alert("请选择文件");
|
|
return;
|
|
}
|
|
fileData.append("file",file);
|
|
$.ajax({
|
|
type:"post",
|
|
url:Url4,
|
|
date:fileData,
|
|
processData:false,
|
|
contentType:false,
|
|
success:function (data,status) {
|
|
if(status=="success")
|
|
{
|
|
alert("选择成功");
|
|
}
|
|
}
|
|
})
|
|
}
|
|
function selectFile() {
|
|
$('.true-select').click();
|
|
}
|
|
function showMsg() {
|
|
var file=$(this).val();
|
|
var filename=getmsg(file);
|
|
function getmsg(file) {
|
|
var index=file.lastIndexOf("\\");
|
|
return file.substring(index+1);
|
|
}
|
|
$('.file-msg').css("opacity","1");
|
|
$('.file-name').html(filename);
|
|
$('.file-msg').css("left","340px");
|
|
$('.file-input-frame').css("right","20px")
|
|
} |