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


PHP FileUploader类代码示例

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


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

示例1: upload

 public function upload()
 {
     global $varChecker;
     if ($varChecker->getValue('fileindex') !== false) {
         $fileindex = $varChecker->getValue('fileindex');
         $fileindex = empty($fileindex) ? 0 : $fileindex;
         $handle = $this->findFilehandle($fileindex);
     } else {
         $handle = $this->findFilehandle();
     }
     $uploader = new FileUploader($handle, true);
     $error = '';
     $path = 'cache/templates/' . $this->INK_User->getCustomer()->getSite()->getId() . '/';
     $fmaker = new FileMaker();
     $fmaker->makeDirectory($path, false);
     //upload the file
     try {
         //upload to cms
         $path = $uploader->upload($path);
         //upload to client server
         $result = array('success' => 'file_uploaded', 'filepath' => $path, 'msg' => 'file uploaded');
     } catch (Exception $e) {
         $result = array('error' => $e->getMessage());
     }
     echo json_encode($result);
 }
开发者ID:ruffen,项目名称:Pixcel-CMS,代码行数:26,代码来源:files.controller.php

示例2: header_image

function header_image()
{
    $header_image_action = $_POST['header_image_option'];
    $display_header_image = $_POST['desktop_image_display'];
    if (!empty($_FILES['headerphoto']['name']) && empty($_POST['restore_default'])) {
        $uploadfile = PA::$upload_path . basename($_FILES['headerphoto']['name']);
        $myUploadobj = new FileUploader();
        //creating instance of file.
        $image_type = 'image';
        $file = $myUploadobj->upload_file(PA::$upload_path, 'headerphoto', true, true, $image_type);
        if ($file == false) {
            throw new PAException(GROUP_PARAMETER_ERROR, "File upload error: " . $myUploadobj->error);
        }
        $header_image = $file;
        $header_img = array('display_header_image' => $display_header_image, 'header_image_action' => $header_image_action, 'header_image' => $header_image);
        return $header_img;
    }
    if (isset($_POST['restore_default'])) {
        $header_image = NULL;
        $header_img = array('display_header_image' => $display_header_image, 'header_image_action' => $header_image_action, 'header_image' => $header_image);
        return $header_img;
    }
    $header_img = array('display_header_image' => $display_header_image, 'header_image_action' => $header_image_action);
    return $header_img;
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:25,代码来源:group_functions.php

示例3: changeSlide

 public function changeSlide($fileName)
 {
     // folder for uploaded files
     $tempFolder = Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . Yii::app()->params['folders']['temp'];
     if (!is_writable($tempFolder)) {
         throw new CException('temporary folder is not exists or not writable. Path:' . $tempFolder);
     }
     $uploader = new FileUploader(Yii::app()->params['uploader']['allowedFileExtensions'], Yii::app()->params['uploader']['sizeLimit']);
     $result = $uploader->handleUpload($tempFolder);
     if (!isset($result['error'])) {
         $imageHandler = new CImageHandler();
         $imageHandler->load($tempFolder . $result['filename']);
         try {
             $imageHandler->cropAndScaleFromCenter(1040, 380);
             $imageHandler->save($this->getSliderImagePath($fileName));
             $this->response = array('fileName' => $fileName, 'imageSrc' => $this->getSliderImageSrc($fileName));
             return TRUE;
         } catch (CException $e) {
             $this->response = array('errorMessage' => $fileName . $e->getMessage());
             return FALSE;
         }
     } else {
         $this->response = array('errorMessage' => $result['error']);
         return FALSE;
     }
 }
开发者ID:andrelinoge,项目名称:rezydent,代码行数:26,代码来源:SliderModel.php

示例4: handle_uploaded_avatar_pic

 function handle_uploaded_avatar_pic()
 {
     if (!empty($_FILES['userfile']['name'])) {
         $uploadfile = PA::$upload_path . basename($_FILES['userfile']['name']);
         $myUploadobj = new FileUploader();
         //creating instance of file.
         $image_type = 'image';
         $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, $image_type);
         if ($file == false) {
             $this->reg_user->msg = $myUploadobj->error;
             $this->reg_user->error = TRUE;
         } else {
             $_POST['user_filename'] = $file;
         }
     } else {
         // IF THE UPLOAD FIELD WAS EMPTY CHECK FOR THE URL FIELD
         $avatar_url = trim(@$_REQUEST['avatar_url']);
         if (!empty($avatar_url) && preg_match("|http://(.*?)/(.*)|", $avatar_url, $m)) {
             //TODO: change to use FileUploader or new storage code.
             list(, $uf_server, $uf_path) = $m;
             $uf_basename = preg_replace("[^A-Za-z0-9\\-_\\.]", "_", basename($uf_path));
             //FETCH THE IMAGE VIA HTTP AND WRITE IT WHERE AN UPLOADED FILE WOULD GO
             $uploadfile = PA::$upload_path . $uf_basename;
             if ($this->reg_user->download($avatar_url, $uploadfile)) {
                 $_POST['user_filename'] = $uf_basename;
                 $_POST['avatar_url'] = '';
             } else {
                 $this->reg_user->msg = "Could not retrieve file from URL:" . $avatar_url;
                 $this->reg_user->error = TRUE;
             }
         }
     }
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:33,代码来源:register.php

示例5: handle_uploaded_avatar_pic

 function handle_uploaded_avatar_pic()
 {
     if (isset($_POST['user_filename'])) {
         $_POST['user_filename'] = Storage::validateFileId($_POST['user_filename']);
     }
     if (!empty($_FILES['userfile']['name'])) {
         // process uploaded image file
         $myUploadobj = new FileUploader();
         $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, 'image');
         if (!$file) {
             throw new PAException(FILE_NOT_UPLOADED, $myUploadobj->error);
         }
     } else {
         // download given image url
         $avatar_url = trim(@$_REQUEST['avatar_url']);
         if (!empty($avatar_url) && preg_match("|http://(.*?)/(.*)|", $avatar_url, $m)) {
             list(, $uf_server, $uf_path) = $m;
             $file = Storage::save($avatar_url, basename($uf_path), "critical", "image");
             if (!$file) {
                 throw new PAException(FILE_NOT_UPLOADED, sprintf(__("Could not retrieve file from URL: %s"), $avatar_url));
             }
         }
     }
     if (@$file) {
         $_POST['user_filename'] = $file;
         $_POST['avatar_url'] = '';
     }
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:28,代码来源:RegistrationPage.php

示例6: upload_file

 function upload_file()
 {
     $name = $_FILES['file']['name'];
     $file = $_FILES['file'];
     $fileUploader = new FileUploader($file, $name);
     $json = $fileUploader->uploadFile();
     echo $json;
 }
开发者ID:mawilliamson,项目名称:version-control,代码行数:8,代码来源:VersionPostPage.php

示例7: do_file_upload

function do_file_upload()
{
    $uploadfile = PA::$upload_path . basename($_FILES['network_image']['name']);
    $myUploadobj = new FileUploader();
    //creating instance of file.
    $image_type = 'image';
    $file = $myUploadobj->upload_file(PA::$upload_path, 'network_image', true, true, $image_type);
    if ($file == false) {
        $r = array('error' => TRUE, 'error_msg' => $myUploadobj->error);
    } else {
        $r = array('error' => FALSE, 'file' => $file);
    }
    return $r;
}
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:14,代码来源:cnnetwork.php

示例8: updateLogo

 /**
  * 更新LOGO
  *
  * @return bool
  */
 public function updateLogo()
 {
     if (!isset($_FILES['qqfile'])) {
         return true;
     }
     $uploader = new FileUploader();
     $result = $uploader->handleUpload('brand');
     if (isset($result['success'])) {
         if ($this->id_image > 0) {
             $image = new Image($this->id_image);
             if (Validate::isLoadedObject($image)) {
                 $image->delete();
             }
         }
         $this->id_image = $result['success']['id_image'];
         return $this->update();
     }
     return false;
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:24,代码来源:Carrier.php

示例9: uploadMedia

 /**
  * Upload media file ,like: image/flash
  *
  * @author  John.meng (цот╤РШ)
  * @since   version - 2006-1-7 12:56:23
  * @param   string  
  *
  */
 function uploadMedia($CurrentUserPathImages, $oldPic = "", $PicType = "Pic", $newWidth = "", $newHeight = "", $CreateIco = false, $IcoWidth = "", $IcoHeight = "")
 {
     $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'application/x-shockwave-flash');
     $maxfilesize = 10000000;
     $FileUploaderObj = new FileUploader($CurrentUserPathImages, $allowed_mimetypes, $maxfilesize);
     $FileUploaderObj->newWidth = $newWidth;
     $FileUploaderObj->newHeight = $newHeight;
     if ($CreateIco && $IcoWidth && $IcoHeight) {
         $FileUploaderObj->CreateIco = $CreateIco;
         $FileUploaderObj->IcoWidth = $IcoWidth;
         $FileUploaderObj->IcoHeight = $IcoHeight;
     }
     if ($_FILES[$PicType]['name'] != "") {
         if ($FileUploaderObj->fetchMedia($PicType)) {
             $FileUploaderObj->setPrefix($PicType . "_");
             if (!$FileUploaderObj->upload()) {
                 echo $FileUploaderObj->getErrors();
             } else {
                 $StrPic = $FileUploaderObj->getSavedFileName();
                 if ($oldPic) {
                     @unlink($CurrentUserPathImages . "/" . $oldPic);
                 }
             }
         }
     } else {
         $StrPic = $oldPic;
     }
     return $StrPic;
 }
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:37,代码来源:FileUploadHandle.class.php

示例10: ajaxProcessAddImage

/**
 * 上传图片并更新排序
 */
function ajaxProcessAddImage()
{
    // max file size in bytes
    $uploader = new FileUploader();
    $result = $uploader->handleUpload(ImageType::IMAGE_PRDOCUT);
    if (isset($result['success'])) {
        $image = $result['success'];
        $row['id_product'] = Tools::Q('id_product');
        $row['id_image'] = (int) $image['id_image'];
        $row['position'] = (int) Product::getImageLastPosition($row['id_product']);
        if ($row['position'] == 1) {
            $row['cover'] = 1;
        } else {
            $row['cover'] = 0;
        }
        Db::getInstance()->insert(DB_PREFIX . 'product_to_image', $row);
        $json = array('status' => 'ok', 'id' => $row['id_image'], 'path' => Image::getImageLink($row['id_image'], 'small'), 'position' => $row['position'], 'cover' => $row['cover']);
        die(json_encode($json));
    } else {
        die(json_encode($result));
    }
}
开发者ID:yiuked,项目名称:tmcart,代码行数:25,代码来源:ajax-img.php

示例11: uploadFileLocal

 public static function uploadFileLocal($fieldName, $fileName = null)
 {
     $fileInfo = self::getFileInfo($fieldName);
     if ($fileInfo === null) {
         return null;
     }
     // Upload all file to storage directory. Its temporary.
     $type = 'files';
     $uploadedFileName = $fileName == null ? $fileInfo->getName() : $fileName;
     $dstPath = FileUploader::getStorageDirectory($type) . $uploadedFileName;
     if (!$fileInfo->saveAs($dstPath)) {
         return null;
     }
     return $type . '/' . $uploadedFileName;
 }
开发者ID:rosko,项目名称:AlmazService,代码行数:15,代码来源:FileUploader.php

示例12: run

 public function run()
 {
     // folder for uploaded files
     $tempFolder = Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . $this->tempFolder;
     if (!is_writable($tempFolder)) {
         throw new CException('temporary folder is not exists or not writable. Path:' . $tempFolder);
     }
     $uploader = new FileUploader($this->allowedFileExtensions, $this->fileLimit);
     $result = $uploader->handleUpload($tempFolder);
     if (!isset($result['error'])) {
         $imageHandler = new CImageHandler();
         $imageHandler->load($tempFolder . $result['filename']);
         try {
             // if min/max weight/height are set - check those conditions
             $this->validateImageDimensions($imageHandler->getWidth(), $imageHandler->getHeight());
             $this->getController()->successfulAjaxResponse(array('fileName' => $imageHandler->getBaseFileName(), 'imageSrc' => '/application' . $this->tempFolder . $imageHandler->getBaseFileName()));
         } catch (CException $e) {
             $errorMsg = $imageHandler->getBaseFileName() . ' - ' . $e->getMessage();
             $this->getController()->unsuccessfulAjaxResponse(array('errorMessage' => $errorMsg));
         }
     } else {
         $this->getController()->unsuccessfulAjaxResponse(array('errorMessage' => $result['error']));
     }
 }
开发者ID:andrelinoge,项目名称:rezydent,代码行数:24,代码来源:UploadImageAction.php

示例13: addAttachment

 /**
  * 
  * @param array $file e.g. $_FILES['photo']
  * @return ConversationAttachment
  */
 public function addAttachment($file)
 {
     $systemFilename = self::findNewFileName($this->config->uploadDir);
     $attachsImgUpConfig = $this->config->imageUploaderConfig;
     $attachsImgUpConfig->uploadDir = $this->config->uploadDir;
     if (in_array($file["type"], $attachsImgUpConfig->acceptedMimeTypes->toArray())) {
         ImageUploader::upload($file, $systemFilename, $attachsImgUpConfig);
     } else {
         FileUploader::upload($file, $systemFilename, $this->config->uploadDir);
     }
     $qb = new QueryBuilder();
     $qb->insert(Tbl::get('TBL_CONVERSATION_ATTACHEMENTS'))->values(array('system_filename' => $systemFilename, 'filename' => $file['name'], 'mime_type' => $file['type']));
     $attachmentId = $this->query->exec($qb->getSQL())->getLastInsertId();
     $filter = new ConversationAttachmentFilter();
     $filter->setId($attachmentId);
     return $this->getAttachment($filter);
 }
开发者ID:alexamiryan,项目名称:stingle,代码行数:22,代码来源:ConversationAttachmentManager.class.php

示例14: upload

 /**
  * @copydoc FileUploader::upload
  *
  * @throws SystemException 'ERR_BAD_FILE_FORMAT'
  */
 public function upload($dir)
 {
     if ($this->getExtension() != 'flv' && file_exists($this->getConfigValue('video.ffmpeg'))) {
         $cmd = $this->getConfigValue('video.ffmpeg') . ' -i ' . $this->file['tmp_name'] . ' -f flv -y  -ar 22050 -ab 32 -b 700000 -s cif ' . ($this->FileObjectName = $this->generateFilename($dir, 'flv'));
         $returnStatus = false;
         /*$result = */
         system($cmd, $returnStatus);
         if ($returnStatus) {
             throw new SystemException('ERR_BAD_FILE_FORMAT', SystemException::ERR_CRITICAL, $this->file['name']);
         }
         $cmd = $this->getConfigValue('video.ffmpeg') . ' -i ' . $this->file['tmp_name'] . ' -vframes 1 -ss 00:00:05' . ' -f image2 -s cif -an ' . $this->FileObjectName . '.jpg';
         system($cmd);
         $result = true;
     } else {
         $result = parent::upload($dir);
     }
     return $result;
 }
开发者ID:energine-cmf,项目名称:energine,代码行数:23,代码来源:VideoUploader.php

示例15: __

                 }
             }
         }
     }
 }
 //code for fields which are common to some sections like description, image
 if ($section == 'video_tours' || $section == 'register_today' || $section == 'network_of_moment' || $section == 'server_announcement' || $section == 'showcase') {
     if (empty($_POST['description'])) {
         $message[] = __('No description provided for network of moment');
     } else {
         $networks_data['description'] = $_POST['description'];
     }
     $image_file = 'network_image';
     if (!empty($_FILES[$image_file]['name'])) {
         //validating and then uploading the network image.
         $uploader = new FileUploader();
         //creating instance of file.
         $file = $uploader->upload_file(PA::$upload_path, $image_file, true, true, 'image');
         if ($file == false) {
             $message[] = __(' For network of moment, ') . $uploader->error;
             $networks_data['network_image'] = null;
         } else {
             $networks_data['network_image'] = $file;
         }
     } else {
         if (!empty($_POST['current_network_image'])) {
             //getting the previously added image from the hidden form field.
             $networks_data['network_image'] = $_POST['current_network_image'];
         } else {
             //setting the image to null.
             $networks_data['network_image'] = null;
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:configure_splash_page.php


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