[TYPO3-ect] uploads support in cool
Steffen Kamper
steffen at sk-typo3.de
Mon Nov 5 01:06:48 CET 2007
"Johannes Künsebeck" <hnes_k at gmx.de> schrieb im Newsbeitrag
news:mailman.1.1194220571.22951.typo3-team-extension-coordination at lists.netfielders.de...
> Hello all,
>
> I have written a small document management extension with lib/div in an
> early version, and it was real fun to code that way, especially with the
> php-templating and the forms lib. Thanks Elmar and the whole MVC
> supporters.
> What I really missed (in both the pi_base and lib/div) was a nice way to
> work with fe_user-uploaded files.
> There is the tx_lib_parameters object with the GPvars, but to access files
> I had to walk through the $_FILES-array by myself, including the strange
> way php handles the array keys in _$FILES, then validate the file-type and
> call move_uploaded_file. I did this by extending the tx_lib_parameters and
> tx_lib_form_base class and it worked well for my needs , but felt a bit
> hackish.
>
> I think FE file-upload is a quite common scenario. So I like to discuss
> with you: Is it useful to have this functionality in cool? Is this in the
> scope of cool?
>
> Regards
>
> Hannes
Hi,
good idea to implement file upload support.
Here is a pice of code I use for FE-Upload, may be it helps for integrating
a working solution.
My snippet is not perfect, it's based on pi_base and estimates input-fields
named $this->prefixId[file][]
function getUploadedFiles($count,$maxsize=1024000) {
$this->fileFunc=t3lib_div::makeInstance('t3lib_basicFileFunctions');
for($i=0;$i<$count;$i++) {
if($_FILES[$this->prefixId]['tmp_name']['file'][$i]!='' &&
$_FILES[$this->prefixId]['size']['file'][$i]<$maxsize) {
$fI =
t3lib_div::split_fileref($_FILES[$this->prefixId]['name']['file'][$i]);
$destFile=$this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']),
$this->uploadDir);
t3lib_div::upload_copy_move($_FILES[$this->prefixId]['tmp_name']['file'][$i],$destFile);
$newFiles[]=basename($destFile);
}
}
return $newFiles;
}
vg Steffen
More information about the TYPO3-team-extension-coordination
mailing list