123 lines
5.6 KiB
Plaintext
123 lines
5.6 KiB
Plaintext
|
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Photo_upload2.aspx.cs" Inherits="Mtxfw.shop._admin.Photo_upload2" %>
|
|||
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|||
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|||
|
|
<head>
|
|||
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|||
|
|
<title>无标题文档</title>
|
|||
|
|
<link href="/css/style.css" rel="stylesheet" type="text/css" />
|
|||
|
|
<script src="/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
|
|||
|
|
<script src="/Scripts/qiniu.min.js" type="text/javascript"></script>
|
|||
|
|
<script src="/Scripts/moment.js" type="text/javascript"></script>
|
|||
|
|
<style type="text/css">*{ margin:0;padding:0;}body{ background-color:#fff;}
|
|||
|
|
body .uploadbox{ background-color:#fff;width:100px; height:32px; margin:10px auto; }
|
|||
|
|
#uploadForm{ position: relative;
|
|||
|
|
display: inline-block;width:100px; height:32px;
|
|||
|
|
text-align:left;
|
|||
|
|
line-height:32px;
|
|||
|
|
border:1px solid #10780a;
|
|||
|
|
background-color:#13b60b;
|
|||
|
|
text-indent:0px;
|
|||
|
|
-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px 3px 3px 3px;
|
|||
|
|
color:#fff;
|
|||
|
|
font-size:16px;
|
|||
|
|
font-weight:bold;
|
|||
|
|
z-index:2;
|
|||
|
|
text-indent:25px;
|
|||
|
|
cursor:pointer;background:#13b60b url(/static/img/iconfont.png) 3px -136px no-repeat;}
|
|||
|
|
#uploadForm input{position: absolute;width:100px; height:32px; left: 0; top: 0; opacity: 0; filter: alpha(opacity=0);}
|
|||
|
|
</style>
|
|||
|
|
<script type="text/javascript">
|
|||
|
|
function judgetime1(){
|
|||
|
|
var thedate = new Date();
|
|||
|
|
return date2str(thedate,"yyyyMMddhhmmss");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function date2str(x,y) {
|
|||
|
|
var z = {y:x.getFullYear(),M:x.getMonth()+1,d:x.getDate(),h:x.getHours(),m:x.getMinutes(),s:x.getSeconds()};
|
|||
|
|
return y.replace(/(y+|M+|d+|h+|m+|s+)/g,function(v) {return ((v.length>1?"0":"")+eval('z.'+v.slice(-1))).slice(-(v.length>2?v.length:2))});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function imgUploading() {
|
|||
|
|
var d = $(window.parent.document);
|
|||
|
|
var tips = d.find("#showimage1");
|
|||
|
|
tips.html(tips.html() + "<li class='ajaxLoaderpic'><img src='/images/ajaxLoader.gif' /></li>");
|
|||
|
|
d.find("#IFUpload2").val(1);
|
|||
|
|
try {
|
|||
|
|
// 七牛云uptoken
|
|||
|
|
var token = "<%=upToken %>";
|
|||
|
|
|
|||
|
|
// config信息 object 参数可选
|
|||
|
|
var config = {
|
|||
|
|
//表示是否使用 cdn 加速域名,为布尔值,true 表示使用,默认为 false。
|
|||
|
|
useCdnDomain: false,
|
|||
|
|
// 是否禁用日志报告,为布尔值,默认为 false。
|
|||
|
|
disableStatisticsReport: true,
|
|||
|
|
// 选择上传域名区域;当为 null 或 undefined 时,自动分析上传域名区域。
|
|||
|
|
retryCount: 3,
|
|||
|
|
// 选择上传域名区域;当为 null 或 undefined 时,自动分析上传域名区域。
|
|||
|
|
region: "",
|
|||
|
|
// 是否开启 MD5 校验,为布尔值;在断点续传时,开启 MD5 校验会将已上传的分片与当前分片进行 MD5 值比对,若不一致,则重传该分片,避免使用错误的分片。读取分片内容并计算 MD5 需要花费一定的时间,因此会稍微增加断点续传时的耗时,默认为 false,不开启。
|
|||
|
|
checkByMD5: false,
|
|||
|
|
// 分片上传时每片的大小
|
|||
|
|
chunkSize: 4,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// putExtra
|
|||
|
|
var putExtra = {
|
|||
|
|
customVars: {}
|
|||
|
|
};
|
|||
|
|
// 定义上传文件
|
|||
|
|
var file = $("#Photo")[0].files[0]
|
|||
|
|
// 设置key key为上传后的文件名 自定义即可
|
|||
|
|
var name = file.name;
|
|||
|
|
var key = "ksd2023/" + judgetime1() + name.substring(name.lastIndexOf("."));
|
|||
|
|
|
|||
|
|
const observable = qiniu.upload(file, key, token, putExtra, config)
|
|||
|
|
// 开始上传
|
|||
|
|
observable.subscribe({
|
|||
|
|
next: (result) => {
|
|||
|
|
//alert(JSON.stringify(result));
|
|||
|
|
//上传进度
|
|||
|
|
//if (response.total.percent > 0) {
|
|||
|
|
/* code ··· */
|
|||
|
|
// }
|
|||
|
|
},
|
|||
|
|
error: (err) => {
|
|||
|
|
//上传失败
|
|||
|
|
/* code ··· */
|
|||
|
|
//alert(JSON.stringify(err)+"00");
|
|||
|
|
},
|
|||
|
|
complete: (res) => {
|
|||
|
|
//上传成功
|
|||
|
|
//alert(JSON.stringify()+"|");
|
|||
|
|
|
|||
|
|
tips.html(tips.html().replace("<li class='ajaxLoaderpic'><img src='/images/ajaxLoader.gif' /></li>", ""));
|
|||
|
|
var strimgurl = tips.html();
|
|||
|
|
var UploadNum = d.find("#UploadNum");
|
|||
|
|
UploadNum.val(parseInt(UploadNum.val()) + 1);
|
|||
|
|
strimgurl += "<li onclick=\"selectimage('image" + UploadNum.val() + "')\" id='image" + UploadNum.val() + "' pic='https://fv.pmhapp.cn/" + res.key + "'><img src='https://fv.pmhapp.cn/" + res.key + "' width='100' /><em></em></li>";
|
|||
|
|
tips.html(strimgurl);
|
|||
|
|
tips.find(".ajaxLoaderpic").hide(300);
|
|||
|
|
IFUpload.val(0);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
} catch (err) {
|
|||
|
|
alert(err);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
</script>
|
|||
|
|
</head>
|
|||
|
|
|
|||
|
|
<body>
|
|||
|
|
<p>
|
|||
|
|
<div class="uploadbox">
|
|||
|
|
<div id="uploadForm"><form method="post" enctype="multipart/form-data" id="Form1" target="_self" action='Photo_upload2.aspx'>
|
|||
|
|
上传图片<input name="Photo" id="Photo" onChange="imgUploading();" type="file" accept="image/*" /><input name="hidyanse" id="hidyanse" type="hidden" value="" />
|
|||
|
|
<input name="hidphotos" id="hidphotos" type="hidden" value="" />
|
|||
|
|
</form></div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
</body>
|
|||
|
|
</html>
|