forked from codler/jQuery-Ajax-Upload
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
28 lines (25 loc) · 777 Bytes
/
upload.php
File metadata and controls
28 lines (25 loc) · 777 Bytes
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
<?php
/* print_r($_POST);
print_r($_FILES);
die(); */
require_once(dirname(__file__) . '/libs/secure_upload.php');
require_once(dirname(__file__) . '/libs/smush.php');
$options = array(
'field' => 'uploads',
'path' => dirname(__file__) . '/demo/img'
);
$r = secure_upload($options);
if ($r['success']) {
foreach ($r['success'] AS $k => $file) {
$o = smush_file($options['path'] . '/' . str_replace('..', '.', $file['filename']));
f::remove($options['path'] . '/' . str_replace('..', '.', $file['filename']));
if ($o && !$o['error']) {
$r['success'][$k]['filename'] = $file['filename'] . ' - optimized :' . $o['percent'] . '%';
} else {
$r['success'][$k]['filename'] = $file['filename'] . ' - ' . print_r($o,true);
}
}
}
echo json_encode($r);
die();
?>