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


PHP FileUpload::setError方法代码示例

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


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

示例1: process

 /**
  * Goes through the array of files and processes them accordingly.
  * The result is an array of the appropiate Resource class that has been
  * created using the ResourceFactory class.
  *
  * @return An array of Upload objects that have already been moved to a safer
  * location.
  */
 function process($destinationFolder)
 {
     // first, check if the upload feature is available
     $config =& Config::getConfig();
     if (!$config->getValue("uploads_enabled")) {
         return FILE_UPLOADS_NOT_ENABLED;
     }
     // array used to store the files that have already been saved
     $uploads = array();
     if ($destinationFolder[strlen($destinationFolder - 1)] != "/") {
         $destinationFolder .= "/";
     }
     foreach ($this->_files as $file) {
         $upload = new FileUpload($file);
         $fileName = $upload->getFileName();
         if ($this->my_move_uploaded_file($upload->getTmpName(), $destinationFolder . $fileName)) {
             $upload->setFolder($destinationFolder);
             $upload->setError(0);
         } else {
             $upload->setError(1);
         }
         array_push($uploads, $upload);
     }
     return $uploads;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:33,代码来源:fileuploads.class.php

示例2: testCantMoveWithError

 public function testCantMoveWithError()
 {
     $samplePath = realpath(__DIR__ . '/Sample') . '/upload.txt';
     $targetPath = realpath(__DIR__ . '/Sample') . '/upload_moved.txt';
     if (!file_exists($samplePath) || filesize($samplePath) == 0) {
         $this->markTestSkipped('Sample upload file could not be read correctly: ' . $samplePath);
         return;
     }
     if (file_exists($targetPath)) {
         if (!unlink($targetPath)) {
             $this->markTestSkipped('Moved upload file remains from old test and could not be removed');
             return;
         }
     }
     $file = new FileUpload();
     $file->setTemporaryPath($samplePath);
     $file->setError(UPLOAD_ERR_CANT_WRITE);
     $this->assertFalse($file->saveTo($targetPath));
     $this->assertFileNotExists($targetPath);
 }
开发者ID:roydejong,项目名称:Enlighten,代码行数:20,代码来源:FileUploadTest.php


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