-
Notifications
You must be signed in to change notification settings - Fork 24
/
qa-markdown-upload.php
54 lines (42 loc) · 1.02 KB
/
qa-markdown-upload.php
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
<?php
class qa_markdown_upload
{
private $imguplopt = 'markdown_uploadimage';
public function match_request($request)
{
return ($request == 'qa-markdown-upload');
}
public function process_request($request)
{
$message = '';
$url = '';
if (is_array($_FILES) && count($_FILES)) {
$uploadimg = qa_opt($this->imguplopt) === '1';
if (!$uploadimg) {
$message = qa_lang('users/no_permission');
header('Content-type: application/json');
echo json_encode([
'error'=>$message
]);
} else {
require_once QA_INCLUDE_DIR.'app/upload.php';
$upload = qa_upload_file_one(
qa_get_max_upload_size(), // do not restrict upload size
true, // force upload to image only
500, // max width (px)
500 // max height (px)
);
$message = @$upload['error'];
$url = @$upload['bloburl'];
$id = @$upload['blobid'];
header('Content-type: application/json');
echo json_encode([
'error'=>$message,
'url'=>$url,
'id'=>$id,
]);
}
}
return null;
}
}