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


PHP FileUploader::upload方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: array

{
    if (isset($array[$value])) {
        return $array[$value];
    } else {
        return "";
    }
}
//Form parameters
$form_action = "uploadhymn.php";
$form_legend = "Ladda upp psalm";
if (isset($_FILES["file"])) {
    $dirs = array("audio/mpeg" => "mp3", "video/ogg" => "ogg", "audio/midi" => "midi");
    $target_dir = "../hymns/" . take($dirs, $_FILES["file"]["type"]) . "/";
    $formats = array("video/ogg", "audio/midi", "audio/mpeg");
    $uploader = new FileUploader();
    if ($uploader->upload($_FILES["file"], $target_dir, $formats)) {
        $form_message = "Filen har laddats upp.";
    } else {
        $form_message = $uploader->error();
    }
}
?>

<html>
  <head>
    <title>Online-Psalmboken</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <p>
      <a href="index.php">Start</a> &raquo;
开发者ID:joelabr,项目名称:Online-Psalmboken,代码行数:31,代码来源:uploadhymn.php

示例6: FileUploader

<?php

require 'authentication.php';
require 'fileuploader.php';
//Form parameters
$form_action = "uploadhymnbook.php";
$form_legend = "Ladda upp psalmbok";
if (isset($_FILES["file"])) {
    $uploader = new FileUploader();
    if ($uploader->upload($_FILES["file"], "../xml/hymnbooks/", array("text/xml"))) {
        $form_message = "Filen har laddats upp.";
    } else {
        $form_message = $uploader->error();
    }
}
?>

<html>
  <head>
    <title>Online-Psalmboken</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <p>
      <a href="index.php">Start</a> &raquo;
      <a href="">Ladda upp psalmbok</a>
    </p>
    <?php 
require 'uploadform.php';
?>
  </body>
开发者ID:joelabr,项目名称:Online-Psalmboken,代码行数:31,代码来源:uploadhymnbook.php

示例7: realpath

/**
 * Base config file
*/
require_once realpath(dirname(__FILE__)) . '/../../config_path.inc.php';
/**
 * Clear node and layout variable in $_SESSION
*/
$variableToClearAR = array('node', 'layout', 'course', 'user');
/**
 * Users (types) allowed to access this module.
*/
$allowedUsersAr = array(AMA_TYPE_SWITCHER);
/**
 * Get needed objects
*/
$neededObjAr = array(AMA_TYPE_SWITCHER => array('layout'));
/**
 * Performs basic controls before entering this module
*/
require_once ROOT_DIR . '/include/module_init.inc.php';
require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php';
require_once ROOT_DIR . '/include/FileUploader.inc.php';
$fileUploader = new FileUploader(ADA_UPLOAD_PATH);
if ($fileUploader->upload() == false) {
    $data = $fileUploader->getErrorMessage();
} else {
    $_SESSION['importHelper']['filename'] = $fileUploader->getPathToUploadedFile();
    $data = '1';
    // '1' means okay
}
echo $data;
开发者ID:eguicciardi,项目名称:ada,代码行数:31,代码来源:upload.php

示例8: realpath

require_once realpath(dirname(__FILE__)) . '/../../../../config_path.inc.php';
/**
 * Clear node and layout variable in $_SESSION
*/
$variableToClearAR = array('node', 'layout', 'course', 'user');
/**
 * Users (types) allowed to access this module.
*/
$allowedUsersAr = array(AMA_TYPE_SWITCHER, AMA_TYPE_STUDENT, AMA_TYPE_AUTHOR, AMA_TYPE_TUTOR);
/**
 * Get needed objects
*/
$neededObjAr = array(AMA_TYPE_STUDENT => array('layout'), AMA_TYPE_SWITCHER => array('layout'), AMA_TYPE_AUTHOR => array('layout'), AMA_TYPE_TUTOR => array('layout'));
/**
 * Performs basic controls before entering this module
*/
$trackPageToNavigationHistory = false;
require_once ROOT_DIR . '/include/module_init.inc.php';
require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php';
require_once ROOT_DIR . '/include/FileUploader.inc.php';
$fileUploader = new FileUploader(ADA_UPLOAD_PATH . $userId . '/');
// $fieldUploadName);
if ($fileUploader->upload(true) == false) {
    $data = $fileUploader->getErrorMessage();
} else {
    $_SESSION['uploadHelper']['filename'] = $fileUploader->getPathToUploadedFile();
    $_SESSION['uploadHelper']['fileNameWithoutPath'] = $fileUploader->getFileName();
    $data = '1';
    // '1' means okay
}
echo $data;
开发者ID:eguicciardi,项目名称:ada,代码行数:31,代码来源:upload.php


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