summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-16 22:03:59 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-16 22:03:59 -0500
commit5a6cd48df19e1d5daf3f70d06052271a8340b147 (patch)
tree8f022538279d6083adfb3f434a457e56870db370
parent47e427457930db38030e1a10e0f3d97a71473371 (diff)
Remove global
-rw-r--r--app/Core/Http/Request.php12
-rw-r--r--app/Model/File.php14
2 files changed, 20 insertions, 6 deletions
diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php
index da95f2d4..1b3036d5 100644
--- a/app/Core/Http/Request.php
+++ b/app/Core/Http/Request.php
@@ -157,6 +157,18 @@ class Request extends Base
}
/**
+ * Get info of an uploaded file
+ *
+ * @access public
+ * @param string $name Form file name
+ * @return array
+ */
+ public function getFileInfo($name)
+ {
+ return isset($this->files[$name]) ? $this->files[$name] : array();
+ }
+
+ /**
* Return HTTP method
*
* @access public
diff --git a/app/Model/File.php b/app/Model/File.php
index daade517..be62cdb3 100644
--- a/app/Model/File.php
+++ b/app/Model/File.php
@@ -263,14 +263,16 @@ class File extends Base
public function uploadFiles($project_id, $task_id, $form_name)
{
try {
- if (empty($_FILES[$form_name])) {
+ $file = $this->request->getFileInfo($form_name);
+
+ if (empty($file)) {
return false;
}
- foreach ($_FILES[$form_name]['error'] as $key => $error) {
- if ($error == UPLOAD_ERR_OK && $_FILES[$form_name]['size'][$key] > 0) {
- $original_filename = $_FILES[$form_name]['name'][$key];
- $uploaded_filename = $_FILES[$form_name]['tmp_name'][$key];
+ foreach ($file['error'] as $key => $error) {
+ if ($error == UPLOAD_ERR_OK && $file['size'][$key] > 0) {
+ $original_filename = $file['name'][$key];
+ $uploaded_filename = $file['tmp_name'][$key];
$destination_filename = $this->generatePath($project_id, $task_id, $original_filename);
if ($this->isImage($original_filename)) {
@@ -283,7 +285,7 @@ class File extends Base
$task_id,
$original_filename,
$destination_filename,
- $_FILES[$form_name]['size'][$key]
+ $file['size'][$key]
);
}
}