libraries/joomla/filesystem/file.php に基づくカスタム フィールドのアップロード メカニズムの作成に問題があります。フォームには、アップロードしていないビューに正しい enctype が設定されています。コンポーネント/モデル/フィールド/uploadfield.php のコードは次のとおりです。
protected function getInput()
{
//Retrieve file details from uploaded file, sent from upload form
$file = JFactory::getApplication()->input->get($this->name, null, 'files', 'array');
//Import filesystem libraries. Perhaps not necessary, but does not hurt
jimport('joomla.filesystem.file');
//Clean up filename to get rid of strange characters like spaces etc
$filename = JFile::makeSafe($file['name']);
//Set up the source and destination of the file
$src = $file['tmp_name'];
$dest = JPATH_COMPONENT . DIRECTORY_SEPARATOR . $filename;
//First check if the file has the right extension, we need jpg only
if ( strtolower(JFile::getExt($filename) ) == 'jpg') {
if ( JFile::upload($src, $dest) ) {
//Redirect to a page of your choice
} else {
//Redirect and throw an error message
}
} else {
//Redirect and notify user file is not right extension
}
return '<input type="file" name="' . $this->name . '" id="' . $this->id . '"' . ' />';
}
getInput() 関数でアップロードメカニズムを使用して、これを正しい方法で行っていますか? それはモデルにあるべきですか?http://docs.joomla.org/How_to_use_the_filesystem_packageに従うことを試みてきましたが、アップロードコードがどこに行くべきかを言うことを怠っていますか?
どうもありがとう