-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUploadImage.php
34 lines (28 loc) · 999 Bytes
/
UploadImage.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
// This is just an example, change it to your specific needs
// This example is intended for images
<?php
namespace Frontend\Modules\Blog\Ajax;
use Frontend\Core\Engine\Base\AjaxAction;
use Frontend\Core\Engine\Model as FrontendModel;
class UploadImage extends AjaxAction
{
public function execute()
{
$files = array_map(
function ($file) {
$filename = md5(uniqid() . time()) . '.' . $file->getClientOriginalExtension();
$file->move(
FRONTEND_FILES_PATH . '/Profiles/acquisitions/source',
$filename
);
Model::generateThumbnails(
FRONTEND_FILES_PATH . '/Profiles/acquisitions/',
FRONTEND_FILES_PATH . '/Profiles/acquisitions/source/' . $filename
);
return $filename;
},
$this->get('request')->files->all()
);
$this->output(self::OK, $files);
}
}