Skip to content

Commit

Permalink
Merge pull request #5 from justcoded/develop
Browse files Browse the repository at this point in the history
Fix file manager name replacement
  • Loading branch information
aprokopenko authored Feb 2, 2018
2 parents 643a835 + d0c522d commit a520728
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/FileManager/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public function upload(array $fields)
$fileField = $_FILES[$field];
$file = new File($fileField);

$name = preg_replace('/[^\00-\255]+/u', '', $file->name);
$name = str_replace('"', '', trim($name));
$path = realpath($this->uploadPath) . '/' . $name . $file->uniqueName;
$name = preg_replace('/[^a-z0-9\-\_\.]+/iu', '', trim($file->name));
$name = preg_replace('/(\.[a-z0-9]+)$/i', '', $name);
$path = realpath($this->uploadPath) . '/' . $name . '-' . $file->uniqueName;

if ($file->error == 0 && move_uploaded_file($file->tmp_name, $path)) {
$file->uploadUrl = $this->uploadUrl . '/' . $name . $file->uniqueName;
$file->uploadUrl = $this->uploadUrl . '/' . $name . '-' . $file->uniqueName;
$file->uploadPath = $path;
$_POST[$field] = $file;
$files[] = $file;
Expand Down

0 comments on commit a520728

Please sign in to comment.