[TYPO3-project-formidable] How to delete a file from a FILE renderlet?
Manuel Rego Casasnovas
mrego at igalia.com
Wed Jun 13 11:49:50 CEST 2007
Hi.
I've a bug in my source code for the _flatten function, I don't check if
the file to delete is a directory or no.
New code:
...
if(move_uploaded_file($tmp_name, $target)) {
$this->oForm->_debug("moving from <b>[" . $tmp_name
. "]</b> to <b>[" . $target . "]</b>", "RDT FILE " . $this->_getName() .
" - FILE CORRECTLY UPLOADED AND STORED");
$sFile = $basename;
$dFile =
$this->getFullServerPath(basename($mData["backup"]));
if(file_exists($dFile) && !is_dir($dFile)) {
unlink($dFile);
}
}
...
I think that you can use this code in the FILE renderlet, because if you
don't delete the uploaded files you have a lot of files in your server
that you don't use.
Bye,
Rego
--
Manuel Rego Casasnovas
Computer Science Engineer
mailto:mrego at igalia.com
Tel: +34 986 10 76 10
Fax: +34 981 91 39 49
Igalia - http://www.igalia.com
Manuel Rego Casasnovas escribió:
> Hi.
>
> I've solved my first problem, I've modified the source code of the
> _flatten function in the tx_rdtfile class, and add three lines:
> ...
> if(move_uploaded_file($tmp_name, $target)) {
>
> $this->oForm->_debug("moving from <b>[" . $tmp_name
> . "]</b> to <b>[" . $target . "]</b>", "RDT FILE " . $this->_getName() .
> " - FILE CORRECTLY UPLOADED AND STORED");
> $sFile = $basename;
>
> // Lines added
> $dFile =
> $this->getFullServerPath(basename($mData["backup"]));
> if(file_exists($dFile)) {
> unlink($dFile);
> }
>
> }
> ...
>
> With this I delete the files, when I upload a new file.
>
> Only one problem now, delete a file without upload another file.
>
>
> Bye,
> Rego
>
>
>
More information about the TYPO3-project-formidable
mailing list