首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >joomla文件上传问题,路径和权限正确

joomla文件上传问题,路径和权限正确
EN

Stack Overflow用户
提问于 2012-10-17 02:15:00
回答 1查看 1.3K关注 0票数 0

大家好,我在joomla文件中放了一些代码,我面临着一个问题,即使文件没有上传,目标路径和文件夹权限也是正确的

以下是代码

代码语言:javascript
复制
$avatar_file = JRequest::getVar('image', null, 'files','array');
            $upfilename= str_replace($replace,'_',$avatar_file['name']);
            //echo JPATH_ROOT.DS.'images'.DS.'easyblog_avatar'.DS;
            //exit;
            print_r($_FILES);
            $arr = '{"google_profile_url":"","show_google_profile_url":""}';
            echo is_uploaded_file($_FILES['image']['tmp_name']).'<br>'.
            //$destFilePath = dirname(dirname(dirname(dirname(__FILE__)))).DS.'images'.DS.'easyblog_avatar'.DS.$user_id.'_'.$upfilename;
            $destFilePath = JPATH_ROOT.DS.'images'.DS.'easyblog_avatar'.DS.$user_id.'_'.$upfilename;
            //if(JFile::upload($avatar_file['tmp_name'], JPATH_ROOT.DS.'images'.DS.$user_id.'_'.$upfilename)){
            if(@move_uploaded_file($_FILES['image']['tmp_name'], $destFilePath)){
                $avatar = $user_id.'_'.$upfilename;
            }

我使用了joomla函数和核心函数来上传文件,但它不是上传的。

请帮帮我。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2012-10-17 02:25:17

代码语言:javascript
复制
    //import joomlas filesystem functions, we will do all the filewriting with joomlas functions
    jimport('joomla.filesystem.file');
    jimport('joomla.filesystem.folder');

  //this is the name of the field in the html form, filedata is the default name for swfupload
$fieldName = 'Filedata';

    //the name of the file in PHP's temp directory that we are going to move to our folder
    $fileTemp = $_FILES[$fieldName]['tmp_name'];


    //always use constants when making file paths, to avoid the possibilty of remote file inclusion
    $uploadPath = JPATH_SITE.DS.'path'.DS.'path'.DS.$fileName;

    if(!JFile::upload($fileTemp, $uploadPath)) 
    {
            echo JText::_( 'ERROR MOVING FILE' );
            return;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12920913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档