当前位置: 首页>>代码示例>>PHP>>正文


PHP uploader::sgetTypeUpload方法代码示例

本文整理汇总了PHP中uploader::sgetTypeUpload方法的典型用法代码示例。如果您正苦于以下问题:PHP uploader::sgetTypeUpload方法的具体用法?PHP uploader::sgetTypeUpload怎么用?PHP uploader::sgetTypeUpload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uploader的用法示例。


在下文中一共展示了uploader::sgetTypeUpload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: switch

                $result['success'] = false;
                switch ($_FILES['attachedfiles_file']['error']) {
                    case UPLOAD_ERR_FORM_SIZE:
                    case UPLOAD_ERR_INI_SIZE:
                        $result['error'] = "Максимальный объем файлов: " . ConvertBtoMB($max_files_size);
                        break;
                    default:
                        $result['error'] = "Ошибка загрузки файла.";
                        break;
                }
            }
            break;
        case 'remove':
            $files = __paramInit('array_int', null, 'files');
            uploader::sremoveFiles($resource, $files);
            $result['onComplete'] = uploader::getRemoveCallback(uploader::sgetTypeUpload($resource));
            $result['success'] = true;
            break;
        default:
            $result['success'] = false;
            $result['error'] = 'Ошибка загрузки файла';
            break;
    }
} else {
    $result['success'] = false;
    $result['error'] = 'Ошибка загрузки файла';
}
//@todo: где встречаются русские символы мы из преобразуем
//в unicode последовательности чтобы json_encode не ругался
foreach (array('onComplete', 'error') as $key) {
    if (isset($result[$key])) {
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:31,代码来源:uploader.php

示例2: updatePreview

function updatePreview($file_id, $resource)
{
    $objResponse =& new xajaxResponse();
    $CFile = new CFile($file_id);
    $path_file = $CFile->path . 'sm_' . $CFile->name;
    if ($CFile->image_size['height'] > portfolio::PREVIEW_MAX_HEIGHT || $CFile->image_size['width'] > portfolio::PREVIEW_MAX_WIDTH) {
        $CFile = $CFile->resizeImage($path_file, portfolio::PREVIEW_MAX_WIDTH, portfolio::PREVIEW_MAX_HEIGHT, 'auto', true);
    } else {
        $CFile = uploader::remoteCopy($CFile->id, $CFile->table, $CFile->path, false, 'sm_f_');
    }
    uploader::sclear($resource);
    // Чистим заменяем
    uploader::screateFile($CFile, $resource);
    $callback = uploader::getCallback(uploader::sgetTypeUpload($resource));
    $template = uploader::getTemplate('uploader.file', 'portfolio/');
    $template = str_replace(array('{idFile}', '{fileName}'), array($CFile->id, $CFile->original_name), $template);
    $objResponse->script("\n        \$\$('#work_preview_file .qq-upload-list').set('html', '{$template}');\n        \$\$('#work_preview_file .qq-upload-list .qq-upload-file').set('href', '" . WDCPREFIX . "/{$path_file}');\n        \$\$('#work_preview_file .qq-upload-list .qq-uploader-fileID').show();\n    ");
    $objResponse->script("\n        \$\$('#work_preview_file .qq-upload-delete').addEvent('click', function() {\n            new Request.JSON({\n                url: '/uploader.php',\n                onSuccess: function(resp) {\n                    if(resp.success) {\n                        \$\$('#work_preview_file .qq-upload-list').set('html', '');\n                        if(resp.onComplete !== undefined) {\n                            eval(resp.onComplete);\n                        }\n                    }  \n                }\n            }).post({\n                'action': 'remove',\n                'files' : [{$CFile->id}],\n                'resource': '{$resource}',\n                'u_token_key': '{$_SESSION['rand']}'\n            });\n        });\n    ");
    $objResponse->script($callback);
    return $objResponse;
}
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:21,代码来源:portfolio.server.php

示例3: editWork

 public function editWork($uid, $params)
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/uploader/uploader.php';
     $params = self::prepareWork($params);
     $error = self::validateWork($params);
     $work_id = $params['id'];
     if (!empty($error)) {
         return $error;
     }
     $update = array('link' => $params['link'], 'name' => antispam($params['work_name']), 'descr' => antispam($params['work_descr']), 'cost' => $params['work_cost'], 'cost_type' => $params['work_cost_type_db_id'], 'time_value' => $params['time_cost'], 'time_type' => $params['work_time_type_db_id'], 'prev_type' => $params['work_preview_type'], 'prof_id' => $params['work_category_db_id']);
     if ($params['video'] != '') {
         $video_link = video_validate($params['video']);
         $video_link = preg_replace("/^http:\\/\\//", '', $video_link);
         $update['video_link'] = $video_link;
         $update['is_video'] = true;
     } else {
         $update['video_link'] = '';
         $update['is_video'] = false;
     }
     if ($uid == $_SESSION['uid'] && !hasPermissions('users')) {
         // автор, не админ, не про меняет заголовок либо текст - отправить на модерирование
         $update['moderator_status'] = !is_pro() ? '0' : '-2';
     }
     if ($params['position_num'] !== NULL) {
         $update['norder'] = intval($params['position_num']);
     }
     $dir = 'users/' . substr($_SESSION['login'], 0, 2) . "/{$_SESSION['login']}/upload/";
     if (isset($params['IDResource']) && is_array($params['IDResource'])) {
         foreach ($params['IDResource'] as $resource) {
             $resources[uploader::sgetTypeUpload($resource)] = $resource;
         }
         if (isset($resources['portfolio'])) {
             $mainFile = current(uploader::sgetFiles($resources['portfolio']));
             if (!empty($mainFile)) {
                 // Если что-то загрузили и не удаляли
                 $MFile = uploader::remoteCopy($mainFile['id'], 'file', $dir, false);
                 uploader::sclear($resources['portfolio']);
                 // Делаем отдельное привью из оригинальной большой картинки  -- @todo ХЗ зачем но раньше так делали
                 if (in_array($MFile->getext(), $GLOBALS['graf_array']) && $MFile->getext() != 'swf') {
                     $MFile->resizeImage($dir . 'tn_' . $MFile->name, self::PREVIEW_MAX_WIDTH, self::PREVIEW_MAX_HEIGHT, 'auto', true);
                 }
                 $update['pict'] = $MFile->name;
                 $is_remove_main_file = true;
             }
         }
         if (isset($resources['pf_preview'])) {
             $preview = current(uploader::sgetFiles($resources['pf_preview']));
             if (!empty($preview)) {
                 // Если что-то загрузили и не удаляли
                 $PFile = uploader::remoteCopy($preview['id'], 'file', $dir, false, 'sm_f_');
                 uploader::sclear($resources['pf_preview']);
                 $update['prev_pict'] = $PFile->name;
                 $is_remove_preview_file = true;
             }
         }
     }
     if ($params['main_file'] == '' && !isset($MFile)) {
         // Удаляем файл
         $update['pict'] = '';
         $is_remove_main_file = true;
     }
     if ($params['preview_file'] == '' && !isset($PFile)) {
         // Удаляем файл
         $update['prev_pict'] = '';
         $is_remove_preview_file = true;
     }
     if ($is_remove_main_file) {
         $cf = new CFile();
         $cf->Delete(0, $dir, $params['old_main_file']);
         // удаляем ранее загруженный файл
     }
     if ($is_remove_preview_file) {
         $cf = new CFile();
         $cf->Delete(0, $dir, $params['old_preview_file']);
         // удаляем ранее загруженный файл
     }
     if (empty($error)) {
         $wmodeAllowValues = array('direct', 'gpu', 'window');
         if (!in_array($params['wmode'], $wmodeAllowValues)) {
             $params['wmode'] = 'window';
         }
         if ($work_id) {
             $update['edit_date'] = 'NOW()';
             $result = $DB->update('portfolio', $update, 'id = ?i AND user_id = ?i', $work_id, $uid);
         } else {
             $update['user_id'] = $uid;
             $result = $DB->insert('portfolio', $update, 'id');
             $work_id = $result;
         }
         if ($MFile && $MFile->getext() == 'swf' && $MFile->id) {
             $res = $DB->query('UPDATE swf_file_params SET wmode = ?, table_name = ? WHERE fid = ?i', $params['wmode'], $MFile->table, $MFile->id);
             if (pg_affected_rows($res) == 0) {
                 $res = $DB->query('INSERT INTO swf_file_params (fid, wmode, table_name) VALUES(?i, ?, ?)', $MFile->id, $params['wmode'], $MFile->table);
             }
         } else {
             if (!$MFile) {
                 $ext = preg_replace("#.*(\\.[a-zA-Z0-9]*)\$#", '$1', $params['main_file']);
                 if (strtolower($ext) == '.swf') {
                     $res = $DB->query('UPDATE swf_file_params SET wmode = ? WHERE fid = (SELECT id FROM file WHERE fname = ?)', $params['wmode'], $params['main_file']);
//.........这里部分代码省略.........
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:101,代码来源:portfolio.php


注:本文中的uploader::sgetTypeUpload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。