-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
52 lines (37 loc) · 879 Bytes
/
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
<?php
require( 'inc/core-minify.php' );
$data = array();
if ( 0 < $_FILES['file']['error'] ) {
$data['result'] = false;
$data['msg'] = 'Error: ' . $_FILES['file']['error'] . '<br>';
}
else {
$filr_content = file_get_contents($_FILES['file']['tmp_name']);
switch ( $_FILES['file']['type']) {
case 'text/html':
$minify_data = minify_html($filr_content);
$ext = "html";
break;
case 'text/css':
$minify_data = minify_css($filr_content);
$ext = "css";
break;
case 'application/x-javascript':
$minify_data = minify_js($filr_content);
$ext = "js";
break;
default:
$minify_data ="";
break;
}
if(!empty($minify_data)) {
$data['result'] = true;
$data['content'] = trim($minify_data);
$data['ext'] = $ext;
} else {
$data['result'] = false;
$data['msg'] = "format not supported.";
}
}
echo json_encode($data);
?>