简体   繁体   English

TYPO3上传文件前端插件

[英]TYPO3 upload file frontend plugin

I am trying to extend tt_address with multible pictures. 我正在尝试使用多张图片扩展tt_address。 But how to I build the upload form and handle it in the myext_pi1.php? 但是,如何构建上传表单并在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... 输出数组时,piVars中没有图像 (但是所有文本区域和文本输入都在其中...

print_r($this->piVars);

Do the actual upload And if... I could access the files in piVars. 进行实际上传如果...,我可以访问piVars中的文件。 Then how do I upload them to uploads/tx_myext/ ? 然后,如何将它们上传到uploads / tx_myext /中? I assume it is using these functions or similar: http://api.typo3.org/typo3v4/master/html/classt3lib__ext_file_functions.html 我假设它正在使用以下功能或类似功能: 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. 如您所知,我的文件不会进入piVars,而会进入_FILES。 Looking into the ext. 看分机。 feupload I could see how to do a fileuplad based on _FILES and not piVars: feupload我可以看到如何基于_FILES而不是piVars做一个fileuplad:

$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. 如果是最佳实践,我不知道。

you have to add enctype to your form. 您必须在表单中添加enctype。 try to debug $_FILES array so you`ll be able to see the uploaded files 尝试调试$ _FILES数组,以便您可以看到上传的文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM