Permalink
Browse files

Skip empty filenames after uploads. Fixes #70.

  • Loading branch information...
1 parent aedf5e8 commit 12fc32f7f8284e2f153142f030a1cf3034843e2f @bobdenotter committed Jan 5, 2013
Showing with 11 additions and 6 deletions.
  1. +9 −3 app/src/Bolt/Content.php
  2. +2 −3 app/src/Bolt/TwigExtension.php
@@ -187,17 +187,23 @@ public function setFromPost($values, $contenttype)
if (!empty($_FILES)) {
foreach ($_FILES as $key => $file) {
+ if (empty($file['name'][0])) {
+ continue; // Skip 'empty' uploads..
+ }
+
$filename = sprintf("%s/files/%s/%s",
- $this->app['paths']['rootpath'], date("Y-m"), safeString($file['name'][0], false, "[]{}()"));
+ $this->app['paths']['rootpath'],
+ date("Y-m"),
+ safeString($file['name'][0], false, "[]{}()"));
$basename = sprintf("/%s/%s", date("Y-m"), safeString($file['name'][0], false, "[]{}()"));
if ($file['error'][0] != UPLOAD_ERR_OK) {
- $this->app['log']->add("Upload: Error occured during upload: " . $file['error'][0], 2);
+ $this->app['log']->add("Upload: Error occured during upload: " . $file['error'][0] ." - " . $filename, 2);
continue;
}
if (substr($key, 0, 11)!="fileupload-") {
- $this->app['log']->add("Upload: skipped an upload that wasn't for Content.", 2);
+ $this->app['log']->add("Upload: skipped an upload that wasn't for Content. - " . $filename, 2);
continue;
}
@@ -297,13 +297,12 @@ public function listcontent($contenttype, $options, $content)
// Loop the array, set records in 'current' to have a 'selected' flag.
foreach($results as $key => $result) {
if (in_array($result->id, $current)) {
- $results->$key['selected'] = true;
+ $results[$key]['selected'] = true;
} else {
- $results->$key['selected'] = false;
+ $results[$key]['selected'] = false;
}
}
-
return $results;
}

0 comments on commit 12fc32f

Please sign in to comment.