如何在joomla上传文件? [英] How to upload a file in joomla?

查看:918
本文介绍了如何在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 Component对于您的要求的确切情况将很难找到。所以你有两个选择:
1.制作你自己的组件
2.自定义其他类似类型的组件,如gallery组件

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆