Skip to content
Permalink
Browse files

#899 restrict custom field file uploads to images and pdfs

  • Loading branch information...
Kieron
Kieron committed Feb 23, 2016
1 parent 8871a7f commit 70b6af59bf868bad7fce2b356effc8ec71696e78
Showing with 4 additions and 16 deletions.
  1. +3 −14 anchor/models/extend.php
  2. +0 −1 anchor/routes/admin.php
  3. +1 −1 index.php
  4. 0 LICENSE → license.md
@@ -154,21 +154,10 @@ public static function files() {
} }
public static function upload($file) { public static function upload($file) {
$storage = PATH . 'content' . DS; $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
$filepath = $uploader->upload($file);
if(!is_dir($storage)) mkdir($storage); return $filepath;
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
// Added rtrim to remove file extension before adding again
$filename = slug(rtrim($file['name'], '.' . $ext)) . '.' . $ext;
$filepath = $storage . $filename;
if(move_uploaded_file($file['tmp_name'], $filepath)) {
return $filepath;
}
return false;
} }
public static function process_image($extend) { public static function process_image($extend) {
@@ -227,7 +227,6 @@
Upload an image Upload an image
*/ */
Route::post('admin/upload', array('before' => 'auth', 'main' => function() { Route::post('admin/upload', array('before' => 'auth', 'main' => function() {
$uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf')); $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
$filepath = $uploader->upload($_FILES['file']); $filepath = $uploader->upload($_FILES['file']);
@@ -23,7 +23,7 @@
define('DS', DIRECTORY_SEPARATOR); define('DS', DIRECTORY_SEPARATOR);
define('ENV', getenv('APP_ENV')); define('ENV', getenv('APP_ENV'));
define('VERSION', '0.10'); define('VERSION', '0.11');
define('PATH', dirname(__FILE__) . DS); define('PATH', dirname(__FILE__) . DS);
define('APP', PATH . 'anchor' . DS); define('APP', PATH . 'anchor' . DS);
File renamed without changes.

0 comments on commit 70b6af5

Please sign in to comment.
You can’t perform that action at this time.