From abfaeaff4d8a6874fd92030afb8a0f0134854fb4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 26 Jun 2011 08:44:31 -0500 Subject: [PATCH] added upload_of validation rule. --- system/input.php | 12 +++++++ system/validation/rules/upload_of.php | 51 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 system/validation/rules/upload_of.php diff --git a/system/input.php b/system/input.php index 1e9fd973..b09ef673 100644 --- a/system/input.php +++ b/system/input.php @@ -69,6 +69,18 @@ public static function old($key = null, $default = null) return Arr::get(Session::get('laravel_old_input', array()), $key, $default); } + /** + * Get an item from the uploaded file data. + * + * @param string $key + * @param mixed $default + * @return array + */ + public static function file($key, $default = null) + { + return Arr::get($_FILES, $key, $default); + } + /** * Hydrate the input data for the request. * diff --git a/system/validation/rules/upload_of.php b/system/validation/rules/upload_of.php new file mode 100644 index 00000000..cf1d3393 --- /dev/null +++ b/system/validation/rules/upload_of.php @@ -0,0 +1,51 @@ +maximum) and $file['size'] > $this->maximum) + { + return false; + } + + if ( ! is_null($this->extensions) and ! in_array(File::extension($file['name']), $this->extensions)) + { + return false; + } + + return true; + } + +} \ No newline at end of file