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


PHP FileManager::uploadFile方法代码示例

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


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

示例1: insertObject

    /**
     * Insert a new submission file.
     * @param $submissionFile SubmissionFile
     * @param $sourceFile string The place where the physical file
     *  resides right now or the file name in the case of an upload.
     *  The file will be copied to its canonical target location.
     * @param $isUpload boolean set to true if the file has just been
     *  uploaded.
     * @return SubmissionFile the inserted file
     */
    function insertObject($submissionFile, $sourceFile, $isUpload = false)
    {
        $fileId = $submissionFile->getFileId();
        if (!is_numeric($submissionFile->getRevision())) {
            // Set the initial revision.
            $submissionFile->setRevision(1);
        }
        if (!is_bool($submissionFile->getViewable())) {
            // Set the viewable default.
            $submissionFile->setViewable(false);
        }
        $params = array((int) $submissionFile->getRevision(), (int) $submissionFile->getSubmissionId(), is_null($submissionFile->getSourceFileId()) ? null : (int) $submissionFile->getSourceFileId(), is_null($submissionFile->getSourceRevision()) ? null : (int) $submissionFile->getSourceRevision(), $submissionFile->getFileType(), (int) $submissionFile->getFileSize(), $submissionFile->getOriginalFileName(), (int) $submissionFile->getFileStage(), (bool) $submissionFile->getViewable() ? 1 : 0, is_null($submissionFile->getUploaderUserId()) ? null : (int) $submissionFile->getUploaderUserId(), is_null($submissionFile->getUserGroupId()) ? null : (int) $submissionFile->getUserGroupId(), is_null($submissionFile->getAssocType()) ? null : (int) $submissionFile->getAssocType(), is_null($submissionFile->getAssocId()) ? null : (int) $submissionFile->getAssocId(), is_null($submissionFile->getGenreId()) ? null : (int) $submissionFile->getGenreId(), $submissionFile->getDirectSalesPrice(), $submissionFile->getSalesType());
        if ($fileId) {
            array_unshift($params, (int) $fileId);
        }
        $this->update(sprintf('INSERT INTO submission_files
				(' . ($fileId ? 'file_id, ' : '') . 'revision, submission_id, source_file_id, source_revision, file_type, file_size, original_file_name, file_stage, date_uploaded, date_modified, viewable, uploader_user_id, user_group_id, assoc_type, assoc_id, genre_id, direct_sales_price, sales_type)
				VALUES
				(' . ($fileId ? '?, ' : '') . '?, ?, ?, ?, ?, ?, ?, ?, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?)', $this->datetimeToDB($submissionFile->getDateUploaded()), $this->datetimeToDB($submissionFile->getDateModified())), $params);
        if (!$fileId) {
            $submissionFile->setFileId($this->_getInsertId('submission_files', 'file_id'));
        }
        $reviewStage = in_array($submissionFile->getFileStage(), array(SUBMISSION_FILE_REVIEW_FILE, SUBMISSION_FILE_REVIEW_ATTACHMENT, SUBMISSION_FILE_REVIEW_REVISION));
        if (!$submissionFile->getName(AppLocale::getPrimaryLocale())) {
            if ($reviewStage) {
                $submissionFile->setName($submissionFile->_generateName(true), AppLocale::getPrimaryLocale());
            } else {
                $submissionFile->setName($submissionFile->_generateName(), AppLocale::getPrimaryLocale());
            }
        } else {
            if ($reviewStage && $submissionFile->getName(AppLocale::getPrimaryLocale()) == $submissionFile->_generateName()) {
                $submissionFile->setName($submissionFile->_generateName(true), AppLocale::getPrimaryLocale());
            }
        }
        $this->updateLocaleFields($submissionFile);
        // Determine the final destination of the file (requires
        // the file id we just generated).
        $targetFilePath = $submissionFile->getFilePath();
        // Only copy the file if it is not yet in the target position.
        if ($isUpload || $sourceFile != $targetFilePath) {
            // Copy the file from its current location to the target destination.
            import('lib.pkp.classes.file.FileManager');
            $fileManager = new FileManager();
            if ($isUpload) {
                $success = $fileManager->uploadFile($sourceFile, $targetFilePath);
            } else {
                assert(is_readable($sourceFile));
                $success = $fileManager->copyFile($sourceFile, $targetFilePath);
            }
            if (!$success) {
                // If the copy/upload operation fails then remove
                // the already inserted meta-data.
                $this->deleteObject($submissionFile);
                $nullVar = null;
                return $nullVar;
            }
        }
        assert(is_readable($targetFilePath));
        return $submissionFile;
    }
开发者ID:jprk,项目名称:pkp-lib,代码行数:70,代码来源:SubmissionFileDAODelegate.inc.php

示例2: fileUpload

 /**
  * Upload a new file.
  */
 function fileUpload($args)
 {
     FilesHandler::parseDirArg($args, $currentDir, $parentDir);
     $currentPath = FilesHandler::getRealFilesDir($currentDir);
     import('lib.pkp.classes.file.FileManager');
     $fileMgr = new FileManager();
     if ($fileMgr->uploadedFileExists('file')) {
         $destPath = $currentPath . '/' . FilesHandler::cleanFileName($fileMgr->getUploadedFileName('file'));
         @$fileMgr->uploadFile('file', $destPath);
     }
     Request::redirect(null, null, 'files', explode('/', $currentDir));
 }
开发者ID:jerico-dev,项目名称:omp,代码行数:15,代码来源:FilesHandler.inc.php

示例3: fileUpload

 /**
  * Upload a new file.
  * @param $args array
  * @param $request PKPRequest
  */
 function fileUpload($args, $request)
 {
     $this->validate();
     $this->_parseDirArg($args, $currentDir, $parentDir);
     $currentPath = $this->_getRealFilesDir($request, $currentDir);
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     if ($fileManager->uploadedFileExists('file')) {
         $destPath = $currentPath . '/' . $this->_cleanFileName($fileManager->getUploadedFileName('file'));
         @$fileManager->uploadFile('file', $destPath);
     }
     $request->redirect(null, null, 'files', explode('/', $currentDir));
 }
开发者ID:jalperin,项目名称:ojs,代码行数:18,代码来源:FilesHandler.inc.php

示例4: uploadFiles

 /**
  * Uploads multiple files and store it into given pathBase. it basicaly 
  * called the uploads single file and iterate it for each files.
  * @param CUploadedFile[] $files multiple files
  * @return boolean true whether the uploads is succeed
  */
 public static function uploadFiles($files, $pathBase = 'cache/')
 {
     $isSuccess = true;
     $path = Yii::app()->basePath . '/../' . $pathBase;
     FileManager::createFolder($path);
     foreach ($files as $index => $file) {
         if (!FileManager::uploadFile($file, $pathBase)) {
             $isSuccess = false;
             break;
         }
     }
     return $isSuccess;
 }
开发者ID:andryluthfi,项目名称:annotation-tools,代码行数:19,代码来源:FileManager.php

示例5: array

    /**
     * @see SubmissionFileDAODelegate::insert()
     * @param $monographFile MonographFile
     * @return MonographFile
     */
    function &insertObject(&$monographFile, $sourceFile, $isUpload = false)
    {
        $fileId = $monographFile->getFileId();
        if (!is_numeric($monographFile->getRevision())) {
            // Set the initial revision.
            $monographFile->setRevision(1);
        }
        if (!is_bool($monographFile->getViewable())) {
            // Set the viewable default.
            $monographFile->setViewable(false);
        }
        $params = array((int) $monographFile->getRevision(), (int) $monographFile->getMonographId(), is_null($monographFile->getSourceFileId()) ? null : (int) $monographFile->getSourceFileId(), is_null($monographFile->getSourceRevision()) ? null : (int) $monographFile->getSourceRevision(), $monographFile->getFileType(), (int) $monographFile->getFileSize(), $monographFile->getOriginalFileName(), (int) $monographFile->getFileStage(), (bool) $monographFile->getViewable(), is_null($monographFile->getUploaderUserId()) ? null : (int) $monographFile->getUploaderUserId(), is_null($monographFile->getUserGroupId()) ? null : (int) $monographFile->getUserGroupId(), is_null($monographFile->getAssocType()) ? null : (int) $monographFile->getAssocType(), is_null($monographFile->getAssocId()) ? null : (int) $monographFile->getAssocId(), is_null($monographFile->getGenreId()) ? null : (int) $monographFile->getGenreId());
        if ($fileId) {
            array_unshift($params, $fileId);
        }
        $this->update(sprintf('INSERT INTO monograph_files
				(' . ($fileId ? 'file_id, ' : '') . 'revision, monograph_id, source_file_id, source_revision, file_type, file_size, original_file_name, file_stage, date_uploaded, date_modified, viewable, uploader_user_id, user_group_id, assoc_type, assoc_id, genre_id)
				VALUES
				(' . ($fileId ? '?, ' : '') . '?, ?, ?, ?, ?, ?, ?, ?, %s, %s, ?, ?, ?, ?, ?, ?)', $this->datetimeToDB($monographFile->getDateUploaded()), $this->datetimeToDB($monographFile->getDateModified())), $params);
        if (!$fileId) {
            $monographFile->setFileId($this->getInsertId('monograph_files', 'monograph_id'));
        }
        $this->updateLocaleFields($monographFile);
        // Determine the final destination of the file (requires
        // the file id we just generated).
        $targetFilePath = $monographFile->getFilePath();
        // Only copy the file if it is not yet in the target position.
        if ($isUpload || $sourceFile != $targetFilePath) {
            // Copy the file from its current location to the target destination.
            import('lib.pkp.classes.file.FileManager');
            if ($isUpload) {
                $success = FileManager::uploadFile($sourceFile, $targetFilePath);
            } else {
                assert(is_readable($sourceFile));
                $success = FileManager::copyFile($sourceFile, $targetFilePath);
            }
            if (!$success) {
                // If the copy/upload operation fails then remove
                // the already inserted meta-data.
                $this->deleteObject($monographFile);
                $nullVar = null;
                return $nullVar;
            }
        }
        assert(is_readable($targetFilePath));
        return $monographFile;
    }
开发者ID:jerico-dev,项目名称:omp,代码行数:52,代码来源:MonographFileDAODelegate.inc.php

示例6: fileUpload

 /**
  * Upload a new file.
  * @param $args array
  * @param $request PKPRequest
  */
 function fileUpload($args, &$request)
 {
     $this->validate();
     $this->_parseDirArg($args, $currentDir, $parentDir);
     $currentPath = $this->_getRealFilesDir($request, $currentDir);
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     if ($success = $fileManager->uploadedFileExists('file')) {
         $destPath = $currentPath . '/' . $this->_cleanFileName($fileManager->getUploadedFileName('file'));
         $success = $fileManager->uploadFile('file', $destPath);
     }
     if (!$success) {
         $templateMgr =& TemplateManager::getManager($request);
         $this->setupTemplate($request, true);
         $templateMgr->assign('pageTitle', 'manager.filesBrowser');
         $templateMgr->assign('message', 'common.uploadFailed');
         $templateMgr->assign('backLink', $request->url(null, null, null, 'files', explode('/', $currentDir)));
         $templateMgr->assign('backLinkLabel', 'manager.filesBrowser');
         return $templateMgr->display('common/message.tpl');
     }
     $request->redirect(null, null, null, 'files', explode('/', $currentDir));
 }
开发者ID:artkuo,项目名称:ocs,代码行数:27,代码来源:FilesHandler.inc.php

示例7: uploadFile

 function uploadFile($fileName, $destFileName)
 {
     return parent::uploadFile($fileName, $this->filesDir . $destFileName);
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:4,代码来源:JournalFileManager.inc.php


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