-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfontpreviewupload.php
More file actions
94 lines (81 loc) · 2.71 KB
/
fontpreviewupload.php
File metadata and controls
94 lines (81 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Widget上传接口
*
* @author lijie1@yulong.com
*
*/
session_start();
header('content-type:text/html;charset=utf-8');
header ("Cache-Control: no-cache, must-revalidate");
require_once ('tasks/Font/FontFile.class.php');
require_once ('tasks/Font/FontDb.class.php');
require_once ('tasks/Font/FontPreview.class.php');
require_once ('lib/WriteLog.lib.php');
require_once 'public/public.php';
try {
$id = isset($_POST['id'])?$_POST['id']:'';
if(!isset($_POST['id'])){
$_msg = "ID不能为空";
echo "<script>window.parent.Finish('".$_msg."');</script>";
exit;
}
$folder = isset($_POST['folder'])?$_POST['folder']:'';
$width = isset($_POST['width'])?$_POST['width']:'';
$height = isset($_POST['height'])?$_POST['height']:'';
//font文件上传
$preview = previewsUpload($id, $folder, $width, $height);
//录入数据库
$font_db = new FontDb();
$font_db->setPreview($preview);
$result = $font_db->addFontPreview();
if(!$result){
$_msg = "上传失败"; //207:数据库插入数据失败
}else{
$_msg = "上传成功"; //0:上传成功
}
echo "<script>window.parent.Finish('".$_msg."');</script>";
}catch (Exception $e){
$_msg = "发生异常,上传不成功";
echo "<script>window.parent.Finish('".$_msg."');</script>";
exit;
}
function previewsUpload($id, $folder, $width, $height)
{
$input = "preview";
$error = $_FILES[$input]['error'];
$f_preview_name = '';
$f_preview_size = 0;
$f_preview_tmp_file = "";
$preview_url = '';
$preview_md5 = '';
$result = get_file_info($input, -1, $f_preview_name, $f_preview_size, $f_preview_tmp_file);
if(!$f_preview_name){
$_msg = "预览文件信息错误,上传失败";
echo "<script>window.parent.Finish('".$_msg."');</script>";
exit;
}
if($result != UPLOAD_ERR_OK){
Log::write("fontupload::get_file_info(preview) failed ERRO NO: ".$result, "log");
// echo get_rsp_result(UPLOAD_FILE_ERR_FILE_INFO);
$_msg = "预览文件信息错误,上传失败";
echo "<script>window.parent.Finish('".$_msg."');</script>";
exit;
}
$font_file = new FontFile();
$font_file->setFolder('..'.$folder);
$f_name = $width.'x'.$height.substr(strrchr($f_preview_name,"."), 0);
$result = $font_file->uploadPreview($error, $f_preview_size, $f_preview_tmp_file,
$f_name, $preview_url, $preview_md5);
if($result != UPLOAD_ERR_OK){
Log::write("fontupload::uploadPreview(Preview) failed ERRO NO: ".$result, "log");
// echo get_rsp_result(UPLOAD_FILE_ERR_FILE_UPLOAD);
$_msg = "预览文件上传失败";
echo "<script>window.parent.Finish('".$_msg."');</script>";
exit;
}
$preview = new FontPreview();
$preview->setPreview($id, $width, $height, $f_name, $preview_url, $f_preview_size, $preview_md5);
return $preview;
}
?>