Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Commit 70b6af5

Browse files
author
Kieron
committed
#899 restrict custom field file uploads to images and pdfs
1 parent 8871a7f commit 70b6af5

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

anchor/models/extend.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,10 @@ public static function files() {
154154
}
155155

156156
public static function upload($file) {
157-
$storage = PATH . 'content' . DS;
157+
$uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
158+
$filepath = $uploader->upload($file);
158159

159-
if(!is_dir($storage)) mkdir($storage);
160-
161-
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
162-
163-
// Added rtrim to remove file extension before adding again
164-
$filename = slug(rtrim($file['name'], '.' . $ext)) . '.' . $ext;
165-
$filepath = $storage . $filename;
166-
167-
if(move_uploaded_file($file['tmp_name'], $filepath)) {
168-
return $filepath;
169-
}
170-
171-
return false;
160+
return $filepath;
172161
}
173162

174163
public static function process_image($extend) {

anchor/routes/admin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@
227227
Upload an image
228228
*/
229229
Route::post('admin/upload', array('before' => 'auth', 'main' => function() {
230-
231230
$uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
232231
$filepath = $uploader->upload($_FILES['file']);
233232

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
define('DS', DIRECTORY_SEPARATOR);
2525
define('ENV', getenv('APP_ENV'));
26-
define('VERSION', '0.10');
26+
define('VERSION', '0.11');
2727

2828
define('PATH', dirname(__FILE__) . DS);
2929
define('APP', PATH . 'anchor' . DS);

LICENSE renamed to license.md

File renamed without changes.

0 commit comments

Comments
 (0)