forked from pandao/editor.md
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
55 lines (44 loc) · 1.64 KB
/
upload.php
File metadata and controls
55 lines (44 loc) · 1.64 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
<?php
/*
* PHP upload demo for Editor.md
*
* @FileName: upload.php
* @Auther: Pandao
* @E-mail: pandao@vip.qq.com
* @CreateTime: 2015-02-13 23:20:04
* @UpdateTime: 2015-02-14 14:52:50
* Copyright@2015 Editor.md all right reserved.
*/
//header("Content-Type:application/json; charset=utf-8"); // Unsupport IE
header("Content-Type:text/html; charset=utf-8");
header("Access-Control-Allow-Origin: *");
require("editormd.uploader.class.php");
error_reporting(E_ALL & ~E_NOTICE);
$path = __DIR__ . DIRECTORY_SEPARATOR;
$url = dirname($_SERVER['PHP_SELF']) . '/';
$savePath = realpath($path . '../uploads/') . DIRECTORY_SEPARATOR;
$saveURL = $url . '../uploads/';
$formats = array(
'image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp')
);
$name = 'editormd-image-file';
if (isset($_FILES[$name]))
{
$imageUploader = new EditorMdUploader($savePath, $saveURL, $formats['image'], false); // Ymdhis表示按日期生成文件名,利用date()函数
$imageUploader->config(array(
'maxSize' => 1024, // 允许上传的最大文件大小,以KB为单位,默认值为1024
'cover' => true // 是否覆盖同名文件,默认为true
));
$imageUploader->appendResult = array(
'meta' => $_POST
);
if ($imageUploader->upload($name))
{
$imageUploader->message('上传成功!', 1);
}
else
{
$imageUploader->message('上传失败!', 0);
}
}
?>