如何在joomla中上传文件? [英] How to upload a file in joomla?
问题描述
我正在 joomla 中制作一个具有名称图像详细信息的简单组件,我必须上传该图像,如何从后端上传图像.使用扩展或自定义哪个更好.你能分享任何好的文章吗?我已经搜索了更多,但由于缺乏对 joomla 的了解而无法找到.希望各位天才帮帮我.
Hi i am making a simple component in joomla having name image detail and i have to upload that image how can i upload image from backend. which one is better using extension or make custom. can you please share any good article for it. i have searched many more but due to lack of idea on joomla cannot find. hope you genius guys help me.
谢谢我提前
推荐答案
Joomla 组件对于您的需求的确切场景将很难找到.所以你有两个选择:1. 制作自己的组件2. 自定义图库组件等其他类似类型的组件
Joomla Component for the exact scenario of your requirement will be very hard to find out. So you've two options: 1. Make your own component 2. Customize other similar type of component like gallery component
如果您正在制作自己的组件,则用于从管理员上的 joomla 组件上传文件:1. 只需使用move_uploaded_file
php 函数.2. 复制此代码,用于 joomla 的标准 fxn :
For uploading file from joomla component on admin if you're making your own component:
1. Just use move_uploaded_file
php function.
2. copy this code, for joomla's standard fxn :
function upload($src, $dest)
{
jimport('joomla.client.helper');
$FTPOptions = JClientHelper::getCredentials('ftp');
$ret = false;
$dest = JPath::clean($dest);
$baseDir = dirname($dest);
if (!file_exists($baseDir)) {
jimport('joomla.filesystem.folder');
JFolder::create($baseDir);
}
if ($FTPOptions['enabled'] == 1) {
jimport('joomla.client.ftp');
$ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
$dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/');
if (is_uploaded_file($src) && $ftp->store($src, $dest))
{
$ret = true;
unlink($src);
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
} else {
if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors
if (JPath::setPermissions($dest)) {
$ret = true;
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR01'));
}
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
}
return $ret;
}
如果你想使用别人的组件并根据需要编辑它,下载它:http://prakashgobhaju.com.np/index.php?option=com_showcase_gallery&view=items&catid=1&Itemid=64记住它是一个画廊组件.
If you want to use other's component and edit it according to need, download it: http://prakashgobhaju.com.np/index.php?option=com_showcase_gallery&view=items&catid=1&Itemid=64 Remember it's a gallery component.
这篇关于如何在joomla中上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!