Joomla自定义用户扩展


Joomla custom user extension

我正在为一个高级前端用户界面编写Joomla 1.5扩展。现在我必须添加一个功能,以便用户可以在前端上传图片,并将其添加到他们的帐户。

有一个标准的Joomla图片上传可用或什么?

谢谢

我有这是我的代码:(还有一些我不能在这里粘贴所有内容)

function deleteLogo($logo)
{
    // define path to file to delete
    $filePath =  'images/stories/members/' . $logo;
    $imagePath =  'images/stories/members/image/' . $image;
    // check if files exists
    $fileExists = JFile::exists($filePath);
    $imageExists = JFile::exists($imagePath);
    if($fileExists)
    {
        // attempt to delete file
        $fileDeleted = JFile::delete($filePath);
    }   
    if($imageExists)
    {
        // attempt to delete file
        $fileDeleted = JFile::delete($imagePath);
    }   
}
function saveLogo($files, $data)
{   
    $uploadFile = JRequest::getVar('logo', null, 'FILES', 'ARRAY');
    $uploadImage = JRequest::getVar('image', null, 'FILES', 'ARRAY');
    $save = true;
    $saveImage = true;
    if (!is_array($uploadFile)) {
        // @todo handle no upload present
        $save = false;
    }
    if ($uploadFile['error'] || $uploadFile['size'] < 1) {
        // @todo handle upload error
        $save = false;
    }
    if (!is_uploaded_file($uploadFile['tmp_name'])) {
        // @todo handle potential malicious attack
        $save = false;
    }
    if (!is_array($uploadImage)) {
        // @todo handle no upload present
        $saveImage = false;
    }
    if ($uploadImage['error'] || $uploadImage['size'] < 1) {
        // @todo handle upload error
        $saveImage = false;
    }
    if (!is_uploaded_file($uploadImage['tmp_name'])) {
        // @todo handle potential malicious attack
        $saveImage = false;
    }
    // Prepare the temporary destination path
    //$config = & JFactory::getConfig();
    //$fileDestination = $config->getValue('config.tmp_path'). DS . JFile::getName($uploadFile['tmp_name']);
    // Move uploaded file
    if($save)
    {
        $this->deleteLogo($data['oldLogo']);
        $fileDestination = 'images/stories/members/' . $data['id'] . '-' . $uploadFile['name'];
        $uploaded = JFile::upload($uploadFile['tmp_name'], $fileDestination);
    }
    if($saveImage)
    {
        $this->deleteLogo($data['oldImage']);
        $fileDestination = 'images/stories/members/image/' .  $data['id'] . '-' . $uploadImage['name'];
        $uploadedImage = JFile::upload($uploadImage['tmp_name'], $fileDestination);
    }
}