joomla中的文件上传问题,路径和权限都是正确的

时间:2012-10-16 18:15:00

标签: file joomla permissions uploading

大家好我把一些代码放在joomla文件中,我遇到的问题是目标路径和文件夹权限是正确的,尽管文件没有上传

这是代码

$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函数和核心函数来上传文件,但它没有上传。

请帮帮我。

由于

1 个答案:

答案 0 :(得分:0)

    //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;
    }