Reputation: 3523
I am trying to extend tt_address with multible pictures. But how to I build the upload form and handle it in the myext_pi1.php?
Form in template:
<input type="file" id="image1" name="tx_myext_pi1[image1]" />
<input type="file" id="image2" name="tx_myext_pi1[image2]" />
No images in piVars when outputting array (but all textareas and text input are there...
print_r($this->piVars);
Do the actual upload And if... I could access the files in piVars. Then how do I upload them to uploads/tx_myext/ ? I assume it is using these functions or similar: http://api.typo3.org/typo3v4/master/html/classt3lib__ext_file_functions.html
UPDATE
As kindly pointed out yo me files does not go into piVars but go into _FILES. Looking into the ext. feupload I could see how to do a fileuplad based on _FILES and not piVars:
$ffunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$path = $ffunc->getUniqueName($_FILES['image1']['name'], t3lib_div::getFileAbsFileName('uploads/pics/'));
t3lib_div::upload_copy_move($_FILES['image1']['tmp_name'], $path);
$file->setFile(basename($path));
This is working. If it is best practice I do not know.
Upvotes: 0
Views: 2335
Reputation: 4641
you have to add enctype to your form. try to debug $_FILES array so you`ll be able to see the uploaded files
Upvotes: 3