• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP fileupload类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_too_large

 public function test_too_large()
 {
     $upload = new fileupload($this->filesystem, '', array('gif'), 100);
     $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');
     $this->assertEquals(1, sizeof($file->error));
     $this->assertEquals('WRONG_FILESIZE', $file->error[0]);
 }
开发者ID:hgchen,项目名称:phpbb,代码行数:7,代码来源:fileupload_remote_test.php


示例2: process_form

 /**
  * {@inheritdoc}
  */
 public function process_form($request, $template, $user, $row, &$error)
 {
     if ($user->data['user_character_id'] == 0) {
         return false;
     }
     if (!class_exists('fileupload')) {
         include $this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext;
     }
     $upload = new \fileupload('AVATAR_', $this->allowed_extensions, 100000, 64, 64, 256, 256, isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false);
     $url = $this->get_eveapi_url($user->data['user_character_id'], $this->config['eveapi_portrait_size']);
     $file = $upload->remote_upload($url, $this->mimetype_guesser);
     $prefix = $this->config['avatar_salt'] . '_';
     $file->clean_filename('avatar', $prefix, $row['id']);
     $destination = $this->config['avatar_path'];
     // Adjust destination path (no trailing slash)
     if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') {
         $destination = substr($destination, 0, -1);
     }
     $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
     if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) {
         $destination = '';
     }
     // Move file and overwrite any existing image
     $file->move_file($destination, true);
     if (sizeof($file->error)) {
         $file->remove();
         $error = array_merge($error, $file->error);
         return false;
     }
     return array('avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), 'avatar_width' => $file->get('width'), 'avatar_height' => $file->get('height'));
 }
开发者ID:Covert-Inferno,项目名称:eve_api_phpbb,代码行数:34,代码来源:eveapi.php


示例3: main

 public function main($id, $mode)
 {
     global $config, $user, $template, $request, $phpbb_container, $phpbb_root_path, $phpEx;
     $user->add_lang_ext('tas2580/mobilenotifier', 'common');
     $wa = $phpbb_container->get('tas2580.mobilenotifier.src.helper');
     $this->tpl_name = 'acp_mobilenotifier_body';
     $this->page_title = $user->lang('ACP_MOBILENOTIFIER_TITLE');
     add_form_key('acp_mobilenotifier');
     // Form is submitted
     if ($request->is_set_post('submit')) {
         if (!check_form_key('acp_mobilenotifier')) {
             trigger_error($user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
         }
         $config->set('whatsapp_sender', $request->variable('sender', ''));
         $config->set('whatsapp_password', $request->variable('password', ''));
         $config->set('whatsapp_status', $request->variable('status', ''));
         $config->set('whatsapp_default_cc', $request->variable('default_cc', ''));
         $wa->update_status($config['whatsapp_status']);
         if ($request->file('image')) {
             include_once $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
             $upload = new \fileupload();
             $upload->set_allowed_extensions(array('jpg', 'png', 'gif'));
             $file = $upload->form_upload('image');
             if ($file->filename) {
                 $wa->update_picture($file->filename);
             }
         }
         trigger_error($user->lang('ACP_SAVED') . adm_back_link($this->u_action));
     }
     $template->assign_vars(array('WA_VERSION' => WA_VER, 'U_ACTION' => $this->u_action, 'SENDER' => isset($config['whatsapp_sender']) ? $config['whatsapp_sender'] : '', 'PASSWORD' => isset($config['whatsapp_password']) ? $config['whatsapp_password'] : '', 'STATUS' => isset($config['whatsapp_status']) ? $config['whatsapp_status'] : '', 'CC_SELECT' => $wa->cc_select(isset($config['whatsapp_default_cc']) ? $config['whatsapp_default_cc'] : '')));
 }
开发者ID:NicolasCapon,项目名称:mobilenotifier,代码行数:31,代码来源:mobilenotifier_module.php


示例4: process_form

 /**
  * {@inheritdoc}
  */
 public function process_form($request, $template, $user, $row, &$error)
 {
     if (!$this->can_upload()) {
         return false;
     }
     if (!class_exists('fileupload')) {
         include $this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext;
     }
     $upload = new \fileupload($this->filesystem, 'AVATAR_', $this->allowed_extensions, $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false);
     $url = $request->variable('avatar_upload_url', '');
     $upload_file = $request->file('avatar_upload_file');
     if (!empty($upload_file['name'])) {
         $file = $upload->form_upload('avatar_upload_file', $this->mimetype_guesser);
     } else {
         if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url)) {
             if (!preg_match('#^(http|https|ftp)://#i', $url)) {
                 $url = 'http://' . $url;
             }
             if (!function_exists('validate_data')) {
                 require $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
             }
             $validate_array = validate_data(array('url' => $url), array('url' => array('string', true, 5, 255)));
             $error = array_merge($error, $validate_array);
             if (!empty($error)) {
                 return false;
             }
             $file = $upload->remote_upload($url, $this->mimetype_guesser);
         } else {
             return false;
         }
     }
     $prefix = $this->config['avatar_salt'] . '_';
     $file->clean_filename('avatar', $prefix, $row['id']);
     $destination = $this->config['avatar_path'];
     // Adjust destination path (no trailing slash)
     if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') {
         $destination = substr($destination, 0, -1);
     }
     $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
     if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) {
         $destination = '';
     }
     // Move file and overwrite any existing image
     $file->move_file($destination, true);
     if (sizeof($file->error)) {
         $file->remove();
         $error = array_merge($error, $file->error);
         return false;
     }
     // Delete current avatar if not overwritten
     $ext = substr(strrchr($row['avatar'], '.'), 1);
     if ($ext && $ext !== $file->get('extension')) {
         $this->delete($row);
     }
     return array('avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), 'avatar_width' => $file->get('width'), 'avatar_height' => $file->get('height'));
 }
开发者ID:Mtechnik,项目名称:phpbb-core,代码行数:59,代码来源:upload.php


示例5: avatar_upload_resize

 public function avatar_upload_resize($row)
 {
     if (!class_exists('fileupload')) {
         include $this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext;
     }
     $upload = new \fileupload('AVATAR_', $this->allowed_extensions, $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_upload_max_width'], $this->config['avatar_upload_max_height'], isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false);
     $file = $upload->form_upload('avatar_upload_file', $this->mimetype_guesser);
     $prefix = $this->config['avatar_salt'] . '_';
     $file->clean_filename('avatar', $prefix, $row['id']);
     // If there was an error during upload, then abort operation
     if (sizeof($file->error)) {
         $file->remove();
         $error = $file->error;
         return false;
     }
     // Calculate new destination
     $destination = $this->config['avatar_path'];
     // Adjust destination path (no trailing slash)
     if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') {
         $destination = substr($destination, 0, -1);
     }
     $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
     if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) {
         $destination = '';
     }
     $destination_file = $this->phpbb_root_path . $destination . '/' . $prefix . $row['id'] . '.' . $file->get('extension');
     $file->move_file($destination, true);
     if (sizeof($file->error)) {
         $file->remove();
         trigger_error(implode('<br />', $file->error));
     }
     // Delete current avatar if not overwritten
     $ext = substr(strrchr($row['avatar'], '.'), 1);
     if ($ext && $ext !== $file->get('extension')) {
         $this->delete($row);
     }
     if ($file->width > $this->max_size || $file->height > $this->max_size) {
         $avatar_info = $this->resize(array('w' => $file->width, 'h' => $file->height, 'ext' => $file->extension), $destination, $destination_file);
         /** New file width & height */
         $file->width = $avatar_info['avatar_width'];
         $file->height = $avatar_info['avatar_height'];
     }
     if ($file->width > $this->config['avatar_max_width'] || $file->height > $this->config['avatar_max_height']) {
         $destination_edit_file = $this->phpbb_root_path . $this->d_edit . '/' . $row['id'] . '.' . $file->get('extension');
         rename($destination_file, $destination_edit_file);
         phpbb_chmod($destination_edit_file, CHMOD_READ);
         chmod($destination_edit_file, 0666);
         redirect($this->helper->route("bb3mobi_AvatarUpload_crop", array('avatar_id' => $row['id'], 'ext' => $file->extension)), false, true);
     }
     return array('avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), 'avatar_width' => $file->width, 'avatar_height' => $file->height);
 }
开发者ID:bb3mobi,项目名称:AvatarUpload,代码行数:51,代码来源:resize.php


示例6: regsiter

 public function regsiter()
 {
     self::setdata();
     $reg = self::wirteData();
     //创建用户目录
     global $usdir;
     $dir = ROOT . DS . US . DS . self::$data[name];
     if (!is_dir($dir)) {
         for ($i = 0; $i < count($usdir); $i++) {
             $newdir = $dir . DS . "{$usdir[$i]}";
             fileupload::create_folders($newdir);
         }
     }
     return $reg;
 }
开发者ID:unionbt,项目名称:secret,代码行数:15,代码来源:login_out_class.php


示例7: upload

 /**
  * 上传图片的方法
  * @return [type] [description]
  */
 public function upload()
 {
     $up = new fileupload();
     //设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
     $up->set("path", $this->imagedir);
     $up->set("maxsize", 2000000);
     $up->set("allowtype", array("gif", "png", "jpg", "jpeg"));
     $up->set("israndname", true);
     //使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false
     if ($up->upload("pic")) {
         $data['imagename'] = $up->getoriginname();
         $data['imageid'] = $up->getFileName();
         $data['imageurl'] = $this->imagebaseurl . $data['imageid'];
         $this->res->setdata($data);
         $this->res->echores();
     } else {
         //获取上传失败以后的错误提示
         $this->res->seterr("4001", $up->getErrorMsg());
         $this->res->echores();
         ///Users/baidu/data/devtools/imagetmp
     }
 }
开发者ID:swordphp,项目名称:devtools,代码行数:26,代码来源:image_ctrl.class.php


示例8: gravatar_process

/**
* Acts in place of the standard avatar processing function. 
*/
function gravatar_process($data, $error)
{
    global $config, $db, $user, $phpbb_root_path, $phpEx;
    // Make sure getimagesize works...
    if (($image_data = @getimagesize($data['gravatar'])) === false && (empty($data['width']) || empty($data['height']))) {
        $error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
        return false;
    }
    if (!empty($image_data) && ($image_data[0] < 2 || $image_data[1] < 2)) {
        $error[] = $user->lang['AVATAR_NO_SIZE'];
        return false;
    }
    $width = $data['width'] && $data['height'] ? $data['width'] : $image_data[0];
    $height = $data['width'] && $data['height'] ? $data['height'] : $image_data[1];
    if ($width < 2 || $height < 2) {
        $error[] = $user->lang['AVATAR_NO_SIZE'];
        return false;
    }
    // Check image type
    include_once $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
    $types = fileupload::image_types();
    if (!isset($types[$image_data[2]])) {
        $error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
    }
    if ($config['avatar_max_width'] || $config['avatar_max_height']) {
        if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height']) {
            $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $width, $height);
            return false;
        }
    }
    if ($config['avatar_min_width'] || $config['avatar_min_height']) {
        if ($width < $config['avatar_min_width'] || $height < $config['avatar_min_height']) {
            $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $width, $height);
            return false;
        }
    }
    return array(AVATAR_REMOTE, $data['gravatar'], $width, $height);
}
开发者ID:jverkoey,项目名称:Three20-Scope,代码行数:41,代码来源:functions_gravatar.php


示例9: upload_attachment

/**
* Upload Attachment - filedata is generated here
* Uses upload class
*
* @param string			$form_name		The form name of the file upload input
* @param int			$forum_id		The id of the forum
* @param bool			$local			Whether the file is local or not
* @param string			$local_storage	The path to the local file
* @param bool			$is_message		Whether it is a PM or not
* @param \filespec		$local_filedata	A filespec object created for the local file
* @param \phpbb\mimetype\guesser	$mimetype_guesser	The mimetype guesser object if used
* @param \phpbb\plupload\plupload	$plupload		The plupload object if one is being used
*
* @return object filespec
*/
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
{
    global $auth, $user, $config, $db, $cache;
    global $phpbb_root_path, $phpEx, $phpbb_dispatcher;
    $filedata = array('error' => array());
    include_once $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
    $upload = new fileupload();
    if ($config['check_attachment_content'] && isset($config['mime_triggers'])) {
        $upload->set_disallowed_content(explode('|', $config['mime_triggers']));
    } else {
        if (!$config['check_attachment_content']) {
            $upload->set_disallowed_content(array());
        }
    }
    $filedata['post_attach'] = $local || $upload->is_valid($form_name);
    if (!$filedata['post_attach']) {
        $filedata['error'][] = $user->lang['NO_UPLOAD_FORM_FOUND'];
        return $filedata;
    }
    $extensions = $cache->obtain_attach_extensions($is_message ? false : (int) $forum_id);
    $upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
    $file = $local ? $upload->local_upload($local_storage, $local_filedata, $mimetype_guesser) : $upload->form_upload($form_name, $mimetype_guesser, $plupload);
    if ($file->init_error) {
        $filedata['post_attach'] = false;
        return $filedata;
    }
    // Whether the uploaded file is in the image category
    $is_image = isset($extensions[$file->get('extension')]['display_cat']) ? $extensions[$file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false;
    if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id)) {
        // Check Image Size, if it is an image
        if ($is_image) {
            $file->upload->set_allowed_dimensions(0, 0, $config['img_max_width'], $config['img_max_height']);
        }
        // Admins and mods are allowed to exceed the allowed filesize
        if (!empty($extensions[$file->get('extension')]['max_filesize'])) {
            $allowed_filesize = $extensions[$file->get('extension')]['max_filesize'];
        } else {
            $allowed_filesize = $is_message ? $config['max_filesize_pm'] : $config['max_filesize'];
        }
        $file->upload->set_max_filesize($allowed_filesize);
    }
    $file->clean_filename('unique', $user->data['user_id'] . '_');
    // Are we uploading an image *and* this image being within the image category?
    // Only then perform additional image checks.
    $file->move_file($config['upload_path'], false, !$is_image);
    // Do we have to create a thumbnail?
    $filedata['thumbnail'] = $is_image && $config['img_create_thumbnail'] ? 1 : 0;
    if (sizeof($file->error)) {
        $file->remove();
        $filedata['error'] = array_merge($filedata['error'], $file->error);
        $filedata['post_attach'] = false;
        return $filedata;
    }
    // Make sure the image category only holds valid images...
    if ($is_image && !$file->is_image()) {
        $file->remove();
        if ($plupload && $plupload->is_active()) {
            $plupload->emit_error(104, 'ATTACHED_IMAGE_NOT_IMAGE');
        }
        // If this error occurs a user tried to exploit an IE Bug by renaming extensions
        // Since the image category is displaying content inline we need to catch this.
        trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
    }
    $filedata['filesize'] = $file->get('filesize');
    $filedata['mimetype'] = $file->get('mimetype');
    $filedata['extension'] = $file->get('extension');
    $filedata['physical_filename'] = $file->get('realname');
    $filedata['real_filename'] = $file->get('uploadname');
    $filedata['filetime'] = time();
    /**
     * Event to modify uploaded file before submit to the post
     *
     * @event core.modify_uploaded_file
     * @var	array	filedata	Array containing uploaded file data
     * @var	bool	is_image	Flag indicating if the file is an image
     * @since 3.1.0-RC3
     */
    $vars = array('filedata', 'is_image');
    extract($phpbb_dispatcher->trigger_event('core.modify_uploaded_file', compact($vars)));
    // Check our complete quota
    if ($config['attachment_quota']) {
        if ($config['upload_dir_size'] + $file->get('filesize') > $config['attachment_quota']) {
            $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
            $filedata['post_attach'] = false;
            $file->remove();
//.........这里部分代码省略.........
开发者ID:Tarendai,项目名称:spring-website,代码行数:101,代码来源:functions_posting.php


示例10: move_file

 /**
  * Move file to destination folder
  * The phpbb_root_path variable will be applied to the destination path
  *
  * @param string $destination Destination path, for example $config['avatar_path']
  * @param bool $overwrite If set to true, an already existing file will be overwritten
  * @param bool $skip_image_check If set to true, the check for the file to be a valid image is skipped
  * @param string $chmod Permission mask for chmodding the file after a successful move. The mode entered here reflects the mode defined by {@link phpbb_chmod()}
  *
  * @access public
  */
 function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false)
 {
     global $user, $phpbb_root_path;
     if (sizeof($this->error)) {
         return false;
     }
     $chmod = $chmod === false ? CHMOD_READ | CHMOD_WRITE : $chmod;
     // We need to trust the admin in specifying valid upload directories and an attacker not being able to overwrite it...
     $this->destination_path = $phpbb_root_path . $destination;
     // Check if the destination path exist...
     if (!file_exists($this->destination_path)) {
         @unlink($this->filename);
         return false;
     }
     $upload_mode = @ini_get('open_basedir') || @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on' ? 'move' : 'copy';
     $upload_mode = $this->local ? 'local' : $upload_mode;
     $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname);
     // Check if the file already exist, else there is something wrong...
     if (file_exists($this->destination_file) && !$overwrite) {
         @unlink($this->filename);
         $this->error[] = $user->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file);
         $this->file_moved = false;
         return false;
     } else {
         if (file_exists($this->destination_file)) {
             @unlink($this->destination_file);
         }
         switch ($upload_mode) {
             case 'copy':
                 if (!@copy($this->filename, $this->destination_file)) {
                     if (!@move_uploaded_file($this->filename, $this->destination_file)) {
                         $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
                     }
                 }
                 break;
             case 'move':
                 if (!@move_uploaded_file($this->filename, $this->destination_file)) {
                     if (!@copy($this->filename, $this->destination_file)) {
                         $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
                     }
                 }
                 break;
             case 'local':
                 if (!@copy($this->filename, $this->destination_file)) {
                     $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
                 }
                 break;
         }
         // Remove temporary filename
         @unlink($this->filename);
         if (sizeof($this->error)) {
             return false;
         }
         phpbb_chmod($this->destination_file, $chmod);
     }
     // Try to get real filesize from destination folder
     $this->filesize = @filesize($this->destination_file) ? @filesize($this->destination_file) : $this->filesize;
     // Get mimetype of supplied file
     $this->mimetype = $this->get_mimetype($this->destination_file);
     if ($this->is_image() && !$skip_image_check) {
         $this->width = $this->height = 0;
         if (($this->image_info = @getimagesize($this->destination_file)) !== false) {
             $this->width = $this->image_info[0];
             $this->height = $this->image_info[1];
             if (!empty($this->image_info['mime'])) {
                 $this->mimetype = $this->image_info['mime'];
             }
             // Check image type
             $types = fileupload::image_types();
             if (!isset($types[$this->image_info[2]]) || !in_array($this->extension, $types[$this->image_info[2]])) {
                 if (!isset($types[$this->image_info[2]])) {
                     $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_INVALID'], $this->image_info[2], $this->mimetype);
                 } else {
                     $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$this->image_info[2]][0], $this->extension);
                 }
             }
             // Make sure the dimensions match a valid image
             if (empty($this->width) || empty($this->height)) {
                 $this->error[] = $user->lang['ATTACHED_IMAGE_NOT_IMAGE'];
             }
         } else {
             $this->error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
         }
     }
     $this->file_moved = true;
     $this->additional_checks();
     unset($this->upload);
     return true;
 }
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:100,代码来源:functions_upload.php


示例11: test_valid_dimensions

 public function test_valid_dimensions()
 {
     $upload = new fileupload($this->filesystem, '', false, false, 1, 1, 100, 100);
     $file1 = $this->gen_valid_filespec();
     $file2 = $this->gen_valid_filespec();
     $file2->height = 101;
     $file3 = $this->gen_valid_filespec();
     $file3->width = 0;
     $this->assertTrue($upload->valid_dimensions($file1));
     $this->assertFalse($upload->valid_dimensions($file2));
     $this->assertFalse($upload->valid_dimensions($file3));
 }
开发者ID:hgchen,项目名称:phpbb,代码行数:12,代码来源:fileupload_test.php


示例12: ini_set

 * $Revision: 2331 $
 * $Id: send_file.php 2331 2009-01-13 00:16:13Z ipso $
 * $Date: 2009-01-12 16:16:13 -0800 (Mon, 12 Jan 2009) $
 */
require_once '../includes/global.inc.php';
$skip_message_check = TRUE;
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
require_once Environment::getBasePath() . 'classes/upload/fileupload.class.php';
//PHP must have the upload and POST max sizes set to handle the largest file upload. If these are too low
//it errors out with a non-helpful error, so set these large and restrict the size in the Upload class.
ini_set('upload_max_filesize', '128M');
ini_set('post_max_size', '128M');
extract(FormVariables::GetVariables(array('action', 'object_type', 'object_id', 'parent_id', 'SessionID')));
$object_type = trim(strtolower($object_type));
Debug::Text('Object Type: ' . $object_type . ' ID: ' . $object_id . ' Parent ID: ' . $parent_id . ' POST SessionID: ' . $SessionID, __FILE__, __LINE__, __METHOD__, 10);
$upload = new fileupload();
switch ($object_type) {
    case 'invoice_config':
        if ($permission->Check('invoice_config', 'add') or $permission->Check('invoice_config', 'edit') or $permission->Check('invoice_config', 'edit_child') or $permission->Check('invoice_config', 'edit_own')) {
            $upload->set_max_filesize(1000000);
            //1mb or less
            //$upload->set_acceptable_types( array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png') ); // comma separated string, or array
            //$upload->set_max_image_size(600, 600);
            $upload->set_overwrite_mode(1);
            $icf = TTnew('InvoiceConfigFactory');
            $icf->cleanStoragePath($current_company->getId());
            $dir = $icf->getStoragePath($current_company->getId());
            if (isset($dir)) {
                @mkdir($dir, 0700, TRUE);
                $upload_result = $upload->upload("filedata", $dir);
                //var_dump($upload ); //file data
开发者ID:alachaum,项目名称:timetrex,代码行数:31,代码来源:upload_file.php


示例13: run

 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $helper = new helper();
     $projectObj = new projects();
     $user = new users();
     $language = new language();
     $language->setModule('tickets');
     $lang = $language->readIni();
     $projects = $projectObj->getUserProjects("open");
     $msgKey = '';
     if (isset($_POST['save'])) {
         $values = array('headline' => $_POST['headline'], 'type' => $_POST['type'], 'description' => $_POST['description'], 'priority' => $_POST['priority'], 'projectId' => $_POST['project'], 'editorId' => implode(',', $_POST['editorId']), 'userId' => $_SESSION['userdata']['id'], 'date' => $helper->timestamp2date(date("Y-m-d H:i:s"), 2), 'dateToFinish' => $_POST['dateToFinish'], 'status' => 3, 'browser' => $_POST['browser'], 'os' => $_POST['os'], 'resolution' => $_POST['resolution'], 'version' => $_POST['version'], 'url' => $_POST['url'], 'editFrom' => $_POST['editFrom'], 'editTo' => $_POST['editTo']);
         if ($values['headline'] === '') {
             $tpl->setNotification('ERROR_NO_HEADLINE', 'error');
         } elseif ($values['description'] === '') {
             $tpl->setNotification('ERROR_NO_DESCRIPTION', 'error');
         } elseif ($values['projectId'] === '') {
             $tpl->setNotification('ERROR_NO_PROJECT', 'error');
         } else {
             $values['date'] = $helper->timestamp2date($values['date'], 4);
             $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 4);
             $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 4);
             $values['editTo'] = $helper->timestamp2date($values['editTo'], 4);
             // returns last inserted id
             $id = $this->addTicket($values);
             //Take the old value to avoid nl character
             $values['description'] = $_POST['description'];
             $values['date'] = $helper->timestamp2date($values['date'], 2);
             $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 2);
             $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 2);
             $values['editTo'] = $helper->timestamp2date($values['editTo'], 2);
             $msgKey = 'TICKET_ADDED';
             $tpl->setNotification('TICKET_ADDED', 'success');
             //Fileupload
             if (htmlspecialchars($_FILES['file']['name']) != '') {
                 $upload = new fileupload();
                 $upload->initFile($_FILES['file']);
                 if ($upload->error == '') {
                     // hash name on server for security reasons
                     $newname = md5($id . time());
                     //Encrypt filename on server
                     $upload->renameFile($newname);
                     if ($upload->upload() === true) {
                         $fileValues = array('encName' => $upload->file_name, 'realName' => $upload->real_name, 'date' => date("Y-m-d H:i:s"), 'ticketId' => $id, 'userId' => $_SESSION['userdata']['id']);
                         $this->addFile($fileValues);
                     } else {
                         $msgKey = 'ERROR_FILEUPLOAD_' . $upload->error . '';
                     }
                 } else {
                     $msgKey = 'ERROR_FILEUPLOAD_' . $upload->error . '';
                 }
             }
             /*
             //Send mail
             $mail = new mailer();
             
             $row = $projectObj->getProject($values['projectId']);
             
             $mail->setSubject(''.$lang['ZYPRO_NEW_TICKET'].' "'.$row['name'].'" ');
             
             $username = $user->getUser($_SESSION['userdata']['id']);
             
             $url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php?act=tickets.showTicket&id='.$id.'';
             
             $mailMsg = "".$lang['NEW_TICKET_MAIL_1']." ".$id." ".$lang['NEW_TICKET_MAIL_2']." ".$username['lastname']." ".$username['firstname']." ".$lang['NEW_TICKET_MAIL_3']." ".$row['name']." ".$lang['NEW_TICKET_MAIL_4']." ".$url." ".$lang['NEW_TICKET_MAIL_5']."";
             
             $mail->setText($mailMsg);
             
             if(is_numeric($values['editorId']) === false ){
             
             	$mails = $user->getMailRecipients($values['projectId']);
             		
             }else{
             			
             	$mails = $user->getSpecificMailRecipients($id);
             		
             }
             		
             
             
             $to = array();
             
             foreach($mails as $row){
             		
             	array_push($to, $row['user']);
             
             }
             
             $mail->sendMail($to);
             */
         }
         $tpl->assign('values', $values);
     }
//.........这里部分代码省略.........
开发者ID:DevelopIdeas,项目名称:leantime,代码行数:101,代码来源:class.newTicket.php


示例14: upload_mod

 function upload_mod()
 {
     global $phpbb_root_path, $phpEx, $template, $user;
     if (!isset($_POST['submit'])) {
         return false;
     }
     if (check_form_key('acp_mods_upload') && isset($_FILES['modupload'])) {
         $user->add_lang('posting');
         // For error messages
         include $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
         $upload = new fileupload();
         // Only allow ZIP files
         $upload->set_allowed_extensions(array('zip'));
         // Let's make sure the mods directory exists and if it doesn't then create it
         if (!is_dir($this->mods_dir)) {
             mkdir($this->mods_dir, octdec($config['am_dir_perms']));
         }
         $file = $upload->form_upload('modupload');
         if (empty($file->filename)) {
             trigger_error($user->lang['NO_UPLOAD_FILE'] . adm_back_link($this->u_action), E_USER_WARNING);
         } else {
             if (!$file->init_error && !sizeof($file->error)) {
                 $file->clean_filename('real');
                 $file->move_file(str_replace($phpbb_root_path, '', $this->mods_dir), true, true);
                 if (!sizeof($file->error)) {
                     include $phpbb_root_path . 'includes/functions_compress.' . $phpEx;
                     $mod_dir = $this->mods_dir . '/' . str_replace('.zip', '', $file->get('realname'));
                     $compress = new compress_zip('r', $file->destination_file);
                     $compress->extract($mod_dir . '_tmp/');
                     $compress->close();
                     $folder_contents = scandir($mod_dir . '_tmp/', 1);
                     // This ensures dir is at index 0
                     // We need to check if there's a main directory inside the temp MOD directory
                     if (sizeof($folder_contents) == 3) {
                         // We need to move that directory then
                         $this->directory_move($mod_dir . '_tmp/' . $folder_contents[0], $this->mods_dir . '/' . $folder_contents[0]);
                     } else {
                         if (!is_dir($mod_dir)) {
                             // Change the name of the directory by moving to directory without _tmp in it
                             $this->directory_move($mod_dir . '_tmp/', $mod_dir);
                         }
                     }
                     $this->directory_delete($mod_dir . '_tmp/');
                     if (!sizeof($file->error)) {
                         $template->assign_vars(array('S_MOD_SUCCESSBOX' => true, 'MESSAGE' => $user->lang['MOD_UPLOAD_SUCCESS'], 'U_RETURN' => $this->u_action));
                     }
                 }
             }
             $file->remove();
             if ($file->init_error || sizeof($file->error)) {
                 trigger_error((sizeof($file->error) ? implode('<br />', $file->error) : $user->lang['MOD_UPLOAD_INIT_FAIL']) . adm_back_link($this->u_action), E_USER_WARNING);
             }
         }
     } else {
         trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
     }
     return true;
 }
开发者ID:kairion,项目名称:customisation-db,代码行数:58,代码来源:acp_mods.php


示例15: avatar_upload

/**
* Avatar upload using the upload class
*/
function avatar_upload($data, &$error)
{
    global $phpbb_root_path, $config, $db, $user, $phpEx;
    // Init upload class
    include_once $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
    $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], explode('|', $config['mime_triggers']));
    if (!empty($_FILES['uploadfile']['name'])) {
        $file = $upload->form_upload('uploadfile');
    } else {
        $file = $upload->remote_upload($data['uploadurl']);
    }
    $prefix = $config['avatar_salt'] . '_';
    $file->clean_filename('avatar', $prefix, $data['user_id']);
    $destination = $config['avatar_path'];
    // Adjust destination path (no trailing slash)
    if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') {
        $destination = substr($destination, 0, -1);
    }
    $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
    if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) {
        $destination = '';
    }
    // Move file and overwrite any existing image
    $file->move_file($destination, true);
    if (sizeof($file->error)) {
        $file->remove();
        $error = array_merge($error, $file->error);
    }
    return array(AVATAR_UPLOAD, $data['user_id'] . '_' . time() . '.' . $file->get('extension'), $file->get('width'), $file->get('height'));
}
开发者ID:Phatboy82,项目名称:phpbbgarage,代码行数:33,代码来源:functions_user.php


示例16: elseif

} elseif ($_POST["mulu"] == 'busios') {
    $topass = BUSIOS;
} elseif ($_POST["mulu"] == 'trainandroid') {
    $topass = TRAINANDROID;
} elseif ($_POST["mulu"] == 'trainios') {
    $topass = TRAINIOS;
} elseif ($_POST["mulu"] == 'documentsbus') {
    $topass = DOCUMENTSBUS;
} elseif ($_POST["mulu"] == 'documentstrain') {
    $topass = DOCUMENTSTRAIN;
} elseif ($_POST["mulu"] == 'documentsother') {
    $topass = DOCUMENTSOTHER;
} else {
    $topass = LAJI;
}
$up = new fileupload();
//设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
$up->set("path", $topass);
$up->set("maxsize", 100000000);
$up->set("allowtype", array("apk", "APK", "ipa", "IPA", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf", "jpg", "bmp", "png", "gif", "rb", "zip"));
$up->set("israndname", false);
//使用对象中的upload方法, 就可以上传文件, 方法需要传一个上传表单的名子 pic, 如果成功返回true, 失败返回false
if ($up->upload("file")) {
    //获取上传后文件名子
    echo "恭喜!" . $up->getFileName() . "上传成功<br/>";
    echo '<br/><input type="button" value="继续上传" name="name" onclick="javascript: window.history.back(-1);"/>';
} else {
    //获取上传失败以后的错误提示
    echo $up->getErrorMsg();
    echo '<br/><input type="button" value="继续上传" name="name" onclick="javascript: window.history.back(-1);"/>';
}
开发者ID:sky15179,项目名称:busapp,代码行数:31,代码来源:upload.php


示例17: upload_ext

 /**
  *
  * @package automod
  * @copyright (c) 2008 phpBB Group
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
  *
  */
 function upload_ext($action)
 {
     $this->listzip();
     $this->user->add_lang('posting');
     // For error messages
     include $this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext;
     $upload = new \fileupload();
     $upload->set_allowed_extensions(array('zip'));
     // Only allow ZIP files
     if (!is_writable($this->ext_dir)) {
         $this->trigger_error($this->user->lang['EXT_NOT_WRITABLE'] . $this->back_link, E_USER_WARNING);
         return false;
     }
     $upload_dir = $this->ext_dir;
     // Make sure the ext/ directory exists and if it doesn't, create it
     if (!is_dir($this->ext_dir)) {
         $this->recursive_mkdir($this->ext_dir);
     }
     // Proceed with the upload
     if ($action == 'upload') {
         $file = $upload->form_upload('extupload');
     } else {
         if ($action == 'upload_remote') {
             $file = $this->remote_upload($upload, $this->request->variable('remote_upload', ''));
         }
     }
     if ($action != 'upload_local') {
         if (empty($file->filename)) {
             $this->trigger_error((sizeof($file->error) ? implode('<br />', $file->error) : $this->user->lang['NO_UPLOAD_FILE']) . $this->back_link, E_USER_WARNING);
             return false;
         } else {
             if ($file->init_error || sizeof($file->error)) {
                 $file->remove();
                 $this->trigger_error((sizeof($file->error) ? implod 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP filter_manager类代码示例发布时间:2022-05-23
下一篇:
PHP filesystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap