Commit bd9014f9 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Upload: cached filename rebuild

parent 9fee1b94
......@@ -318,7 +318,6 @@ class BuildFormBootstrap extends AbstractBuildForm {
'use strict';
QfqNS.Log.level = 0;
var qfqPage = new QfqNS.QfqPage({
tabsId: '$tabId',
formId: '$formId',
......
......@@ -386,3 +386,5 @@ const FILES_NAME = 'name';
const FILES_TMP_NAME = 'tmp_name';
const FILES_ERROR = 'error';
const FILES_SIZE = 'size';
const UPLOAD_CACHED = '.cached';
\ No newline at end of file
......@@ -50,9 +50,11 @@ class File {
$oldArr = $this->store->getVar($keyStoreExtra, STORE_EXTRA, SANITIZE_ALLOW_ALL);
// Exist old cached upload? remove.
if (isset($oldArr[FILES_TMP_NAME]) && $oldArr[FILES_TMP_NAME] != '' && file_exists($oldArr[FILES_TMP_NAME] . '.cached')) {
$filenameCached = Support::extendFilename($oldArr[FILES_TMP_NAME], UPLOAD_CACHED);
if (isset($oldArr[FILES_TMP_NAME]) && $oldArr[FILES_TMP_NAME] != '' && file_exists($filenameCached)) {
if (!unlink($oldArr[FILES_TMP_NAME] . '.cached')) {
throw new UserFormException("Failed to delete previous temporary uploaded file: " . $oldArr[FILES_TMP_NAME] . '.cached', ERROR_DELETE_TMP_UPLOAD);
throw new UserFormException("Failed to delete cached uploaded file: " . $filenameCached, ERROR_DELETE_TMP_UPLOAD);
}
}
......@@ -60,8 +62,10 @@ class File {
throw new UserFormException($this->uploadErrMsg[$newArr[FILES_ERROR]], ERROR_UPLOAD);
}
move_uploaded_file($newArr[FILES_TMP_NAME], $newArr[FILES_TMP_NAME] . '.cached');
$filenameCached = Support::extendFilename($newArr[FILES_TMP_NAME], UPLOAD_CACHED);
move_uploaded_file($newArr[FILES_TMP_NAME], $filenameCached);
$this->store->setVar($keyStoreExtra, $newArr, STORE_EXTRA);
}
}
\ No newline at end of file
......@@ -526,4 +526,13 @@ class Support {
$arr[$index] = $value;
}
/**
* @param $filename
* @param $extend
* @return string
*/
public static function extendFilename($filename, $extend) {
return $filename . $extend;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment