增加返回值
parent
927d853e9f
commit
9aaf795d7c
|
@ -49,13 +49,14 @@ if ($handle->uploaded) {
|
||||||
if ($handle->processed) {
|
if ($handle->processed) {
|
||||||
header('Content-type:text/json');
|
header('Content-type:text/json');
|
||||||
// 上传成功后返回json数据
|
// 上传成功后返回json数据
|
||||||
$imageUrl = $config['imgurl'] . config_path() . $handle->file_dst_name;
|
$pathIMG = config_path() . $handle->file_dst_name;
|
||||||
|
$imageUrl = $config['imgurl'] . $pathIMG;
|
||||||
|
|
||||||
// 关闭上传后显示加密删除链接
|
// 关闭上传后显示加密删除链接
|
||||||
if ($config['show_user_hash_del']) {
|
if ($config['show_user_hash_del']) {
|
||||||
// 判断PHP版本启用删除
|
// 判断PHP版本启用删除
|
||||||
if (PHP_VERSION >= '7') {
|
if (PHP_VERSION >= '7') {
|
||||||
$delUrl = $config['domain'] . '/application/del.php?hash=' . urlHash(config_path() . $handle->file_dst_name, 0);
|
$delUrl = $config['domain'] . '/application/del.php?hash=' . urlHash($pathIMG, 0);
|
||||||
} else {
|
} else {
|
||||||
$delUrl = "Sever PHP version lower 7.0";
|
$delUrl = "Sever PHP version lower 7.0";
|
||||||
}
|
}
|
||||||
|
@ -64,11 +65,12 @@ if ($handle->uploaded) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$reJson = array(
|
$reJson = array(
|
||||||
"result" => "success",
|
"result" => "success",
|
||||||
"code" => 200,
|
"code" => 200,
|
||||||
"url" => $imageUrl,
|
"url" => $imageUrl,
|
||||||
"thumb" => $config['domain'] . '/application/thumb.php?img=' . config_path() . $handle->file_dst_name,
|
"srcName" => $handle->file_src_name_body,
|
||||||
"del" => $delUrl,
|
"thumb" => $config['domain'] . '/application/thumb.php?img=' . $pathIMG,
|
||||||
|
"del" => $delUrl,
|
||||||
);
|
);
|
||||||
echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
|
echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
|
||||||
$handle->clean();
|
$handle->clean();
|
||||||
|
@ -93,14 +95,14 @@ if ($handle->uploaded) {
|
||||||
if (function_exists('fastcgi_finish_request')) {
|
if (function_exists('fastcgi_finish_request')) {
|
||||||
fastcgi_finish_request();
|
fastcgi_finish_request();
|
||||||
// 日志
|
// 日志
|
||||||
if ($config['upload_logs']) @write_log(config_path() . $handle->file_dst_name, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
if ($config['upload_logs']) @write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
||||||
// 水印
|
// 水印
|
||||||
@water($handle->file_dst_pathname);
|
@water($handle->file_dst_pathname);
|
||||||
// 压缩
|
// 压缩
|
||||||
@compress($handle->file_dst_pathname);
|
@compress($handle->file_dst_pathname);
|
||||||
} else {
|
} else {
|
||||||
// 日志
|
// 日志
|
||||||
if ($config['upload_logs']) write_log(config_path() . $handle->file_dst_name, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
if ($config['upload_logs']) write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
||||||
// 水印
|
// 水印
|
||||||
@water($handle->file_dst_pathname);
|
@water($handle->file_dst_pathname);
|
||||||
// 压缩
|
// 压缩
|
||||||
|
|
|
@ -61,14 +61,16 @@ if ($handle->uploaded) {
|
||||||
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
|
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
|
||||||
if ($handle->processed) {
|
if ($handle->processed) {
|
||||||
header('Content-type:text/json');
|
header('Content-type:text/json');
|
||||||
|
|
||||||
// 上传成功后返回json数据
|
// 上传成功后返回json数据
|
||||||
$imageUrl = $config['imgurl'] . config_path() . $handle->file_dst_name;
|
$pathIMG = config_path() . $handle->file_dst_name;
|
||||||
|
$imageUrl = $config['imgurl'] . $pathIMG;
|
||||||
|
|
||||||
// 关闭上传后显示加密删除链接
|
// 关闭上传后显示加密删除链接
|
||||||
if ($config['show_user_hash_del']) {
|
if ($config['show_user_hash_del']) {
|
||||||
// 判断PHP版本启用删除
|
// 判断PHP版本启用删除
|
||||||
if (PHP_VERSION >= '7') {
|
if (PHP_VERSION >= '7') {
|
||||||
$delUrl = $config['domain'] . '/application/del.php?hash=' . urlHash(config_path() . $handle->file_dst_name, 0);
|
$delUrl = $config['domain'] . '/application/del.php?hash=' . urlHash($pathIMG, 0);
|
||||||
} else {
|
} else {
|
||||||
$delUrl = "Sever PHP version lower 7.0";
|
$delUrl = "Sever PHP version lower 7.0";
|
||||||
}
|
}
|
||||||
|
@ -77,10 +79,12 @@ if ($handle->uploaded) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$reJson = array(
|
$reJson = array(
|
||||||
"result" => "success",
|
"result" => "success",
|
||||||
"code" => 200,
|
"code" => 200,
|
||||||
"url" => $imageUrl,
|
"url" => $imageUrl,
|
||||||
"del" => $delUrl,
|
"srcName" => $handle->file_src_name_body,
|
||||||
|
"thumb" => $config['domain'] . '/application/thumb.php?img=' . $pathIMG,
|
||||||
|
"del" => $delUrl,
|
||||||
);
|
);
|
||||||
echo json_encode($reJson);
|
echo json_encode($reJson);
|
||||||
$handle->clean();
|
$handle->clean();
|
||||||
|
@ -119,14 +123,14 @@ if ($handle->uploaded) {
|
||||||
if (function_exists('fastcgi_finish_request')) {
|
if (function_exists('fastcgi_finish_request')) {
|
||||||
fastcgi_finish_request();
|
fastcgi_finish_request();
|
||||||
// 日志
|
// 日志
|
||||||
if ($config['upload_logs']) @write_log(config_path() . $handle->file_dst_name, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
if ($config['upload_logs']) @write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
||||||
// 水印
|
// 水印
|
||||||
@water($handle->file_dst_pathname);
|
@water($handle->file_dst_pathname);
|
||||||
// 压缩
|
// 压缩
|
||||||
@compress($handle->file_dst_pathname);
|
@compress($handle->file_dst_pathname);
|
||||||
} else {
|
} else {
|
||||||
// 日志
|
// 日志
|
||||||
if ($config['upload_logs']) write_log(config_path() . $handle->file_dst_name, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
if ($config['upload_logs']) write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
||||||
// 水印
|
// 水印
|
||||||
@water($handle->file_dst_pathname);
|
@water($handle->file_dst_pathname);
|
||||||
// 压缩
|
// 压缩
|
||||||
|
|
18
index.php
18
index.php
|
@ -94,6 +94,10 @@ mustLogin();
|
||||||
chunk_size: 0,
|
chunk_size: 0,
|
||||||
// 点击文件列表上传文件
|
// 点击文件列表上传文件
|
||||||
browseByClickList: true,
|
browseByClickList: true,
|
||||||
|
// flash 上传组件地址
|
||||||
|
flash_swf_url: 'public/static/zui/lib/uploader/Moxie.swf',
|
||||||
|
// silverlight 上传组件地址
|
||||||
|
flash_swf_url: 'public/static/zui/lib/uploader/Moxie.xap',
|
||||||
// 预览图尺寸
|
// 预览图尺寸
|
||||||
previewImageSize: {
|
previewImageSize: {
|
||||||
'width': 80,
|
'width': 80,
|
||||||
|
@ -114,7 +118,7 @@ mustLogin();
|
||||||
},
|
},
|
||||||
// 限制文件上传数目
|
// 限制文件上传数目
|
||||||
limitFilesCount: <?php echo $config['maxUploadFiles']; ?>,
|
limitFilesCount: <?php echo $config['maxUploadFiles']; ?>,
|
||||||
// 自动上传失败的文件
|
// 重置上传失败的文件
|
||||||
autoResetFails: true,
|
autoResetFails: true,
|
||||||
<?php echo imgRatio(); ?>,
|
<?php echo imgRatio(); ?>,
|
||||||
responseHandler: function(responseObject, file) {
|
responseHandler: function(responseObject, file) {
|
||||||
|
@ -123,21 +127,21 @@ mustLogin();
|
||||||
console.log(obj); // 输出log
|
console.log(obj); // 输出log
|
||||||
if (obj.result === 'success') {
|
if (obj.result === 'success') {
|
||||||
var links = document.getElementById("links");
|
var links = document.getElementById("links");
|
||||||
links.innerHTML += obj.url + "\n";
|
links.innerHTML += obj.url + "\r\n";
|
||||||
|
|
||||||
var bbscode = document.getElementById("bbscode");
|
var bbscode = document.getElementById("bbscode");
|
||||||
bbscode.innerHTML += "[img]" + obj.url + "[/img]\n";
|
bbscode.innerHTML += "[img]" + obj.url + "[/img]\r\n";
|
||||||
|
|
||||||
var markdown = document.getElementById("markdown");
|
var markdown = document.getElementById("markdown");
|
||||||
markdown.innerHTML += "\n";
|
markdown.innerHTML += "\r\n";
|
||||||
|
|
||||||
var html = document.getElementById("html");
|
var html = document.getElementById("html");
|
||||||
html.innerHTML += "<img src=\"" + obj.url + "\" alt=\"简单图床 - EasyImage\" />\n";
|
html.innerHTML += '<img src="' + obj.url + '" alt="' + obj.srcName + '" />\r\n';
|
||||||
|
|
||||||
var del = document.getElementById("del");
|
var del = document.getElementById("del");
|
||||||
del.innerHTML += obj.del + "\n";
|
del.innerHTML += obj.del + "\r\n";
|
||||||
} else {
|
} else {
|
||||||
return '上传失败,服务器返回错误:' + obj.message;
|
return '上传失败,服务器返回错误:' + obj.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue