Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
bd9014f9
Commit
bd9014f9
authored
Apr 26, 2016
by
Carsten Rose
Browse files
Upload: cached filename rebuild
parent
9fee1b94
Changes
4
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/BuildFormBootstrap.php
View file @
bd9014f9
...
...
@@ -318,7 +318,6 @@ class BuildFormBootstrap extends AbstractBuildForm {
'use strict';
QfqNS.Log.level = 0;
var qfqPage = new QfqNS.QfqPage({
tabsId: '$tabId',
formId: '$formId',
...
...
extension/qfq/qfq/Constants.php
View file @
bd9014f9
...
...
@@ -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
extension/qfq/qfq/File.php
View file @
bd9014f9
...
...
@@ -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
]
.
'.c
ached
'
,
ERROR_DELETE_TMP_UPLOAD
);
throw
new
UserFormException
(
"Failed to delete
cached
uploaded file: "
.
$
filenameC
ached
,
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
extension/qfq/qfq/helper/Support.php
View file @
bd9014f9
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment