mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-29 09:16:48 +01:00
Fixed file uploads to media streams
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# v1.8.2
|
# v1.8.2
|
||||||
## mm/dd/2018
|
## mm/dd/2018
|
||||||
|
|
||||||
1. [](#bugfix)
|
1. [](#new)
|
||||||
* Added custom object support for filepicker field
|
* Added custom object support for filepicker field
|
||||||
|
|
||||||
# v1.8.1
|
# v1.8.1
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class AdminBaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle errors and breaks without proceeding further
|
// Handle errors and breaks without proceeding further
|
||||||
if ($upload->file->error != UPLOAD_ERR_OK) {
|
if ($upload->file->error !== UPLOAD_ERR_OK) {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD', null),
|
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD', null),
|
||||||
@@ -780,7 +780,7 @@ class AdminBaseController
|
|||||||
$folder = Folder::getRelativePath(rtrim($folder, '/'));
|
$folder = Folder::getRelativePath(rtrim($folder, '/'));
|
||||||
$folder = $this->admin->getPagePathFromToken($folder);
|
$folder = $this->admin->getPagePathFromToken($folder);
|
||||||
|
|
||||||
$media = new Media($folder);
|
$media = new Media($folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
$available_files = [];
|
$available_files = [];
|
||||||
|
|||||||
@@ -1687,9 +1687,16 @@ class AdminController extends AdminBaseController
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var UniformResourceLocator $locator */
|
||||||
|
$locator = $this->grav['locator'];
|
||||||
|
$path = $media->path();
|
||||||
|
if ($locator->isStream($path)) {
|
||||||
|
$path = $locator->findResource($path, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Upload it
|
// Upload it
|
||||||
if (!move_uploaded_file($_FILES['file']['tmp_name'],
|
if (!move_uploaded_file($_FILES['file']['tmp_name'],
|
||||||
sprintf('%s/%s', $media->path(), $_FILES['file']['name']))
|
sprintf('%s/%s', $path, $_FILES['file']['name']))
|
||||||
) {
|
) {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
|
|||||||
Reference in New Issue
Block a user