KaTeX parse error: Expected 'EOF', got '#' at position 3: ("#̲video-upload").…(obj).is(".ri-close-line")) {
$(“input#video”).val(’’);
return ;
}
let rel = $(“input#video”).off().trigger(“click”);
event.preventDefault();
if(rel){
$(“input#video”).change(function () {
if(this.files.length > 0){
var objUrl = getObjectURL(this.files[0]);
if(objUrl){
var formFile = new FormData();
formFile.append(“action”, “UploadVMKImagePath”);
formFile.append(“file”, this.files[0]); //加入文件对象
var data = formFile;
uploads(data);
}
}
})
}
return ;
});
function uploads(data){
$.ajax({
url: “/shop/uploadVideo”,
data: data,
type: “Post”,
dataType: “json”,
cache: false,//上传文件无需缓存
processData: false,//用于对data参数进行序列化处理 这里必须false
contentType: false, //必须
success: function (result) {
// $("#video").val(result.data.file);
}
})
}
//建立一个可存取到该file的url
function getObjectURL(file) {
var url = null;
if (window.createObjectURL != undefined) { // basic
url = window.createObjectURL(file);
} else if (window.URL != undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file);
} else if (window.webkitURL != undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file);
}
return url;
}
js 上传图片
这段代码展示了如何使用JavaScript处理视频上传,包括触发点击事件、创建文件URL、构建FormData对象并使用AJAX进行POST请求上传。主要涉及前端文件上传、事件处理和Ajax交互。

被折叠的 条评论
为什么被折叠?



