增加返回值

pull/18/head
= 2022-02-05 09:23:57 +01:00
parent 927d853e9f
commit 9aaf795d7c
3 changed files with 34 additions and 24 deletions

View File

@ -49,13 +49,14 @@ if ($handle->uploaded) {
if ($handle->processed) {
header('Content-type:text/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']) {
// 判断PHP版本启用删除
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 {
$delUrl = "Sever PHP version lower 7.0";
}
@ -64,11 +65,12 @@ if ($handle->uploaded) {
}
$reJson = array(
"result" => "success",
"code" => 200,
"url" => $imageUrl,
"thumb" => $config['domain'] . '/application/thumb.php?img=' . config_path() . $handle->file_dst_name,
"del" => $delUrl,
"result" => "success",
"code" => 200,
"url" => $imageUrl,
"srcName" => $handle->file_src_name_body,
"thumb" => $config['domain'] . '/application/thumb.php?img=' . $pathIMG,
"del" => $delUrl,
);
echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
$handle->clean();
@ -93,14 +95,14 @@ if ($handle->uploaded) {
if (function_exists('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);
// 压缩
@compress($handle->file_dst_pathname);
} 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);
// 压缩

View File

@ -61,14 +61,16 @@ if ($handle->uploaded) {
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
if ($handle->processed) {
header('Content-type:text/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']) {
// 判断PHP版本启用删除
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 {
$delUrl = "Sever PHP version lower 7.0";
}
@ -77,10 +79,12 @@ if ($handle->uploaded) {
}
$reJson = array(
"result" => "success",
"code" => 200,
"url" => $imageUrl,
"del" => $delUrl,
"result" => "success",
"code" => 200,
"url" => $imageUrl,
"srcName" => $handle->file_src_name_body,
"thumb" => $config['domain'] . '/application/thumb.php?img=' . $pathIMG,
"del" => $delUrl,
);
echo json_encode($reJson);
$handle->clean();
@ -119,14 +123,14 @@ if ($handle->uploaded) {
if (function_exists('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);
// 压缩
@compress($handle->file_dst_pathname);
} 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);
// 压缩

View File

@ -94,6 +94,10 @@ mustLogin();
chunk_size: 0,
// 点击文件列表上传文件
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: {
'width': 80,
@ -114,7 +118,7 @@ mustLogin();
},
// 限制文件上传数目
limitFilesCount: <?php echo $config['maxUploadFiles']; ?>,
// 自动上传失败的文件
// 重置上传失败的文件
autoResetFails: true,
<?php echo imgRatio(); ?>,
responseHandler: function(responseObject, file) {
@ -123,21 +127,21 @@ mustLogin();
console.log(obj); // 输出log
if (obj.result === 'success') {
var links = document.getElementById("links");
links.innerHTML += obj.url + "\n";
links.innerHTML += obj.url + "\r\n";
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");
markdown.innerHTML += "![简单图床 - EasyImage](" + obj.url + ")\n";
markdown.innerHTML += "![" + obj.srcName + "](" + obj.url + ")\r\n";
var html = document.getElementById("html");
html.innerHTML += "&lt;img src=\"" + obj.url + "\" alt=\"简单图床 - EasyImage\" /&#62;\n";
html.innerHTML += '<img src="' + obj.url + '" alt="' + obj.srcName + '" />\r\n';
var del = document.getElementById("del");
del.innerHTML += obj.del + "\n";
del.innerHTML += obj.del + "\r\n";
} else {
return '上传失败服务器返回错误:' + obj.message;
return '上传失败,服务器返回错误:' + obj.message;
}
}
});