From 65d1e7c5cb394108a47f1f6104135264a3ac291d Mon Sep 17 00:00:00 2001 From: colymba Date: Tue, 7 Aug 2012 22:40:12 +0300 Subject: [PATCH] API: custom upload folder Possibility to set a custom upload folder through Component $config --- code/GridFieldBulkImageUpload.php | 3 ++- code/GridFieldBulkImageUpload_Request.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/code/GridFieldBulkImageUpload.php b/code/GridFieldBulkImageUpload.php index 0205317..35d13dc 100644 --- a/code/GridFieldBulkImageUpload.php +++ b/code/GridFieldBulkImageUpload.php @@ -18,7 +18,8 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH 'imageFieldName' => null, 'editableFields' => null, 'fieldsClassBlacklist' => array( 'GridField', 'UploadField' ), - 'fieldsNameBlacklist' => array() + 'fieldsNameBlacklist' => array(), + 'folderName' => 'bulkUpload' ); /** diff --git a/code/GridFieldBulkImageUpload_Request.php b/code/GridFieldBulkImageUpload_Request.php index c45aa71..b3918f3 100644 --- a/code/GridFieldBulkImageUpload_Request.php +++ b/code/GridFieldBulkImageUpload_Request.php @@ -235,7 +235,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { $uploadField->setConfig('url', $this->Link('upload')); - $uploadField->setFolderName(ASSETS_DIR); + //$uploadField->setFolderName(ASSETS_DIR); $form = new Form( @@ -314,7 +314,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { // Get the uploaded file into a new file object. try { - $upload->loadIntoFile($tmpfile, $fileObject, 'Uploads/bulk'); + $upload->loadIntoFile($tmpfile, $fileObject, $this->component->getConfig('folderName')); } catch (Exception $e) { // we shouldn't get an error here, but just in case $return['error'] = $e->getMessage();