Merge pull request #2837 from chillu/pulls/2836-upload-filename-filter

Use filtered file paths in upload (fixes #2836)
This commit is contained in:
Sean Harvey 2014-02-10 14:48:10 +13:00
commit e9f3073fc9

View File

@ -129,17 +129,12 @@ class Upload extends Controller {
$base = Director::baseFolder(); $base = Director::baseFolder();
$parentFolder = Folder::find_or_make($folderPath); $parentFolder = Folder::find_or_make($folderPath);
// Create a folder for uploading.
if(!file_exists(ASSETS_PATH . "/" . $folderPath)){
Filesystem::makeFolder(ASSETS_PATH . "/" . $folderPath);
}
// Generate default filename // Generate default filename
$nameFilter = FileNameFilter::create(); $nameFilter = FileNameFilter::create();
$file = $nameFilter->filter($tmpFile['name']); $file = $nameFilter->filter($tmpFile['name']);
$fileName = basename($file); $fileName = basename($file);
$relativeFilePath = ASSETS_DIR . "/" . $folderPath . "/$fileName"; $relativeFilePath = $parentFolder->getRelativePath() . "/$fileName";
// Create a new file record (or try to retrieve an existing one) // Create a new file record (or try to retrieve an existing one)
if(!$this->file) { if(!$this->file) {