0

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

请帮我。

谢谢

4

1 回答 1

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;
    }
于 2012-10-16T18:25:17.253 回答