分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

图片上传

发布时间:2023-09-06 01:28责任编辑:沈小雨关键词:暂无标签

摘要---保存

一.验证图片格式JS:

  

/** 提交照片表单 */
function uploadImg() {
var photo = $("#pathForm .uploadInput").val();
var ends = photo.split(".")[1];
if (ends!="png" && ends!="jpg" && ends!="jpeg") {
util.dialog.error("照片格式有误,请重新选择!");
return;
}
$("#pathForm")[0].submit();
}
/**
* 提交照片回调函数
* ???处理回调后显示照片
* @param path
*/
function callback(path, photoId) {
if (path == null) {
util.dialog.error("图片上传失败,请重试!");
return;
} else if (path == "fileTooBig") {
util.dialog.error("图片大小超过1MB,请重试!");
???????return;
}
var html = ‘<li class="fl">‘;
html += ‘<input type="hidden" class="photoId" value="‘+photoId+‘" />‘;
html += ‘<div class="imgDelDiv"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></div>‘;
html += ‘<div class="doorImg"><img src="‘+r.host+path+‘" /></div></li>‘;
$(".room_imgUl").append(html);
// 绑定点击放大
$(".doorImg img").last().bind("click", function(){
showBigImg($(this));
});
// 绑定删除图片
$(".imgDelDiv").last().bind("click", function(){
delImg($(this));
});
}
/** 图片点击放大 **/
function showBigImg($this) {
var imgUrl = $this.attr("src");
art.dialog({
???????content : ‘<img style="max-height:600px;" src="‘+imgUrl+‘" />‘,
???????lock : true
???});
}
/** 删除图片 **/
function delImg($this) {
var delPhotoId = $this.parent().find(".photoId").val();
if (delPhotoId == null || delPhotoId == "") {
util.dialog.error("删除照片失败,请刷新后重试");
}
util.ajax(r.host+"house/house/editFsRoom/delImg", {
fsRoomId: $("#fsRoomId").val(),
delPhotoId: delPhotoId
}, function(msg){
$this.parent().remove();
});
}

图片上传

原文地址:http://www.cnblogs.com/kxkl123/p/7732551.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved