From 616dab8bcaffb3ae2c22a51c84314ebe259401d4 Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Mon, 16 Feb 2009 15:44:32 +0000
Subject: Added the ability to pass $config['file_name'] for the File Uploading
Class and rename the uploaded file.
---
system/libraries/Upload.php | 7 ++++---
user_guide/changelog.html | 6 ++++++
user_guide/libraries/file_uploading.html | 10 ++++++++++
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 6309caee3..03a7b21f6 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -911,11 +911,11 @@ class CI_Upload {
{
return $filename;
}
-
+
$parts = explode('.', $filename);
$ext = array_pop($parts);
$filename = array_shift($parts);
-
+
foreach ($parts as $part)
{
if ($this->mimes_types(strtolower($part)) === FALSE)
@@ -928,7 +928,8 @@ class CI_Upload {
}
}
- // file name override
+ // file name override, since the exact name is provided, no need to
+ // run it through a $this->mimes check.
if ($this->file_name != '')
{
$filename = $this->file_name;
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index a9eec099c..19d85c073 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -62,11 +62,17 @@ Change Log
SVN Revision:
+ - Libraries
+
+ - Added the ability to pass $config['file_name'] for the File Uploading Class and rename the uploaded file.
+
+
- Database
- Switched from using gettype() in escape() to is_* methods, since future PHP versions might change its output.
+
Bug fixes for 1.7.2
diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html
index 652aaa528..1051dcbb1 100644
--- a/user_guide/libraries/file_uploading.html
+++ b/user_guide/libraries/file_uploading.html
@@ -259,6 +259,16 @@ $this->upload->initialize($config);
+
+file_name |
+None |
+Desired file name |
+
+ If set CodeIgniter will rename the uploaded file to this name.
+ Note:The filename should not include a file extension.
+ |
+
+
overwrite |
FALSE |
--
cgit v1.2.3-24-g4f1b