summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-11 10:44:52 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-11 10:44:52 +0200
commit6b5ee00bb10dc073c3d70aa7b218efa9265933c5 (patch)
treea12fb3fcbdb92dd94264f671dac953c128b478e2
parent4db16326a0418776f10802ecdcccb385ff67e363 (diff)
parent0ee287ea08de5f3098a27230dcd8ca242b2eb793 (diff)
Merge pull request #1454 from IT-Can/upload-index-1453
Upload library: data() index support
-rw-r--r--system/libraries/Upload.php14
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/libraries/file_uploading.rst4
3 files changed, 16 insertions, 3 deletions
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 1f6aeeb6b..c96daaf15 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -347,11 +347,12 @@ class CI_Upload {
* Returns an associative array containing all of the information
* related to the upload, allowing the developer easy access in one array.
*
- * @return array
+ * @param string
+ * @return mixed
*/
- public function data()
+ public function data($index = NULL)
{
- return array(
+ $data = array(
'file_name' => $this->file_name,
'file_type' => $this->file_type,
'file_path' => $this->upload_path,
@@ -367,6 +368,13 @@ class CI_Upload {
'image_type' => $this->image_type,
'image_size_str' => $this->image_size_str,
);
+
+ if ( ! empty($index))
+ {
+ return isset($data[$index]) ? $data[$index] : NULL;
+ }
+
+ return $data;
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 027163db7..984183a13 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -146,6 +146,7 @@ Release Date: Not Released
- Added a Redis driver to the :doc:`Caching Library <libraries/caching>`.
- Added dsn (delivery status notification) option to the :doc:`Email Library <libraries/email>`.
- Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library <libraries/email>`.
+ - Added a index parameter to the data() function in the Upload library.
- Core
diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst
index d573fc770..414d84f0b 100644
--- a/user_guide_src/source/libraries/file_uploading.rst
+++ b/user_guide_src/source/libraries/file_uploading.rst
@@ -287,6 +287,10 @@ data related to the file you uploaded. Here is the array prototype::
[image_size_str] => width="800" height="200"
)
+To return one element from the array::
+
+ $this->upload->data('file_name'); // Returns: mypic.jpg
+
Explanation
***********