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


PHP UploadedFile::openFile方法代码示例

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


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

示例1: import

 /**
  * Import match plan from text file
  * @param Tournament $tournament Import related to tournament
  * @param String $date Date of match
  * @param String $importStr Match plan - must follow this syntax:
  *                          - Match no
  *                          - Match date (local format - j-m-Y)
  *                          - Match time (local format - G.i)
  *                          - Category name
  *                          - Group name
  *                          - Playground no
  *                          - Home team
  *                                  team name 'division' (country)
  *                                  rank group name
  *                          - Away team
  *                                  team name 'division' (country)
  *                                  rank group name
  *
  * Examples:    385;10-7-2015;13.00;C;(A);7;1 A;2 B
  *              212;5-7-2015;9.15;C;A;7;AETNA MASCALUCIA (ITA);TVIS KFUM 'A' (DNK)
  *
  * Country is only used if team name is ambigious - however syntax must be maintained.
  * Division can be ommitted.
  */
 public function import(UploadedFile $uploadedFile)
 {
     $keys = array("matchno", "date", "time", "category", "group", "playground", "teamA", "teamB");
     $matches = array();
     if ($uploadedFile->isValid() && $uploadedFile->isFile()) {
         /* @var $file SplFileObject */
         $file = $uploadedFile->openFile();
         while (!$file->eof()) {
             $csv = $file->fgetcsv(";");
             $match = array();
             foreach ($csv as $idx => $data) {
                 if ($data) {
                     if (array_key_exists($idx, $keys)) {
                         if ($keys[$idx] == 'teamA' || $keys[$idx] == 'teamB') {
                             $match[$keys[$idx]] = $this->parseImportTeam($data);
                         } else {
                             $match[$keys[$idx]] = $data;
                         }
                     } else {
                         $match[] = $data;
                     }
                 }
             }
             if (count($match) > 0) {
                 $matches[] = $match;
             }
         }
     }
     return $matches;
 }
开发者ID:armandomeeuwenoord,项目名称:icup,代码行数:54,代码来源:MatchPlanningController.php

示例2: createFromUploadedFile

 public static function createFromUploadedFile(UploadedFile $uploadedFile)
 {
     $dto = new self();
     $dto->setFilename($uploadedFile->getClientOriginalName());
     $content = '';
     $file = $uploadedFile->openFile();
     $file->rewind();
     while (false === $file->eof()) {
         $content .= $file->fgets();
     }
     $dto->setContent($content);
     return $dto;
 }
开发者ID:northdakota,项目名称:DiamanteDeskBundle,代码行数:13,代码来源:AttachmentInput.php

示例3: importFromXLS

 /**
  * Extract stories from an XLS file
  * /!\ Not implemented
  *
  * @param UploadedFile $uploadedFile Jira File
  * @return void
  */
 private function importFromXLS(UploadedFile $uploadedFile)
 {
     $file = $uploadedFile->openFile();
     $objReader = \PHPExcel_IOFactory::createReader(\PHPExcel_IOFactory::identify($file->getRealPath()));
     $objReader->setReadDataOnly(true);
     $objPHPExcel = $objReader->load($file->getRealPath());
     $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
     // Till false, we try to find all mandatory field Title in the row to
     // determinate in which row the data are
     $colsFound = false;
     // Rows
     foreach ($sheetData as $rowKey => $rowData) {
         // Try to in which columns data are
         if (!$colsFound) {
             // Fields coordonnate
             // Mandatory
             $key = null;
             $summary = null;
             $type = null;
             // Optionnal
             $effort = null;
             $project = null;
             $version = null;
             $epic = null;
             // Cols
             foreach ($rowData as $colKey => $colValue) {
                 if ($colValue == self::KEY_NAME) {
                     $key = $colKey;
                 }
                 if ($colValue == self::SUMMARY_NAME) {
                     $summary = $colKey;
                 }
                 if ($colValue == self::ISSUE_NAME) {
                     $type = $colKey;
                 }
                 if ($colValue == self::EFFORT_NAME) {
                     $effort = $colKey;
                 }
                 if ($colValue == self::PROJECT_NAME) {
                     $project = $colKey;
                 }
                 if ($colValue == self::VERSION_NAME) {
                     $version = $colKey;
                 }
                 if ($colValue == self::EPIC_NAME) {
                     $epic = $colKey;
                 }
             }
             // Do we found all mandatory fields?
             if (!is_null($key) && !is_null($summary) && !is_null($type)) {
                 $colsFound = true;
             }
         } elseif ('' != $rowData[$key] && '' != $rowData[$summary] && '' != $rowData[$type]) {
             $this->stories->addStory(new Story(array('key' => $rowData[$key], 'summary' => $rowData[$summary], 'type' => $rowData[$type], 'project' => !is_null($project) ? $rowData[$project] : null, 'effort' => !is_null($effort) ? $rowData[$effort] : null, 'link' => null, 'version' => !is_null($version) ? $rowData[$version] : null, 'epic' => !is_null($epic) ? $rowData[$epic] : null)));
         }
     }
 }
开发者ID:primeminister,项目名称:AgileStoryPrint,代码行数:64,代码来源:StoryCard.php


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