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


PHP File::getSize方法代码示例

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


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

示例1: replaceFromFilesystem

 /**
  * Replaces the current file with a new file.
  *
  * @param UploadedFile $file           The target file
  * @param File         $filesystemFile The source file
  */
 public function replaceFromFilesystem(UploadedFile $file, File $filesystemFile)
 {
     $file->setOriginalFilename($filesystemFile->getBasename());
     $file->setExtension($filesystemFile->getExtension());
     $file->setMimeType($filesystemFile->getMimeType());
     $file->setSize($filesystemFile->getSize());
     $storage = $this->getStorage($file);
     if ($filesystemFile->getSize() > $this->container->get("partkeepr_systemservice")->getFreeDiskSpace()) {
         throw new DiskSpaceExhaustedException();
     }
     $storage->write($file->getFullFilename(), file_get_contents($filesystemFile->getPathname()), true);
 }
开发者ID:fulcrum3d,项目名称:PartKeepr,代码行数:18,代码来源:UploadedFileService.php

示例2: setFileAttribute

 public function setFileAttribute(\Symfony\Component\HttpFoundation\File\File $file)
 {
     $this->attributes['file'] = $file;
     $this->original_name = $file instanceof UploadedFile ? $file->getClientOriginalName() : $file->getFilename();
     $this->size = $file->getSize();
     $this->content_type = $file->getMimeType();
 }
开发者ID:AniartUA,项目名称:crm,代码行数:7,代码来源:File.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param File $file A File instance
  */
 public function __construct(File $file)
 {
     if ($file instanceof UploadedFile) {
         parent::__construct($file->getPathname(), $file->getClientOriginalName(), $file->getClientMimeType(), $file->getClientSize(), $file->getError(), true);
     } else {
         parent::__construct($file->getPathname(), $file->getBasename(), $file->getMimeType(), $file->getSize(), 0, true);
     }
 }
开发者ID:sfblaauw,项目名称:pulsar-uploader,代码行数:13,代码来源:FilesystemFile.php

示例4: setFile

 /**
  * @param File|null $file
  */
 public function setFile(File $file = null)
 {
     $this->file = $file;
     $this->fileMimeType = $this->file->getMimeType();
     $this->fileSize = $this->file->getSize();
     if ($this->file instanceof UploadedFile) {
         $this->fileOriginalName = $this->file->getClientOriginalName();
     }
     //        dump($this);
 }
开发者ID:Koc,项目名称:stfalcon-test-task,代码行数:13,代码来源:Photo.php

示例5: __construct

 /**
  * @param string|null $pathname
  */
 public function __construct($pathname = null)
 {
     $this->pathname = $pathname;
     if ($pathname) {
         $file = new SfFile($pathname);
         $this->name = $file->getBasename();
         $this->id = $this->name;
         $this->mimeType = $file->getMimeType();
         $this->size = $file->getSize();
     }
 }
开发者ID:kgilden,项目名称:php-digidoc,代码行数:14,代码来源:File.php

示例6: fromFile

 /**
  * Creates a file object from a file on the disk.
  */
 public function fromFile($filePath)
 {
     if ($filePath === null) {
         return;
     }
     $file = new FileObj($filePath);
     $this->file_name = $file->getFilename();
     $this->file_size = $file->getSize();
     $this->content_type = $file->getMimeType();
     $this->disk_name = $this->getDiskName();
     $this->putFile($uploadedFile->getRealPath(), $this->disk_name);
 }
开发者ID:tamboer,项目名称:LaravelOctober,代码行数:15,代码来源:File.php

示例7: setFile

 /**
  * Set file.
  *
  * @param UploadedFile $file
  *
  * @return $this
  */
 public function setFile(UploadedFile $file = null)
 {
     $this->file = $file;
     $this->setUpdatedAt(new \DateTime());
     if ($file) {
         $this->mimeType = $file->getMimeType();
         $this->fileSize = $file->getSize();
     } else {
         $this->mimeType = null;
         $this->fileSize = null;
     }
     return $this;
 }
开发者ID:tweedegolf,项目名称:media-bundle,代码行数:20,代码来源:AbstractFile.php

示例8: create

 /**
  * {@inheritDoc}
  */
 public function create(File $file)
 {
     $mc = $this->getMediaClass();
     $baseFile = new $mc();
     $baseFile->setPath($file->getPathname());
     $baseFile->setName($file->getClientOriginalName());
     if ($baseFile instanceof BaseFile) {
         $baseFile->setCreatedAt(new \DateTime());
         $baseFile->setSize($file->getSize());
         $baseFile->setContentType($file->getMimeType());
     }
     return $baseFile;
 }
开发者ID:P3PO,项目名称:VlabsMediaBundle,代码行数:16,代码来源:AbstractHandler.php

示例9: testSizeFailing

 public function testSizeFailing()
 {
     $dir = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'directory';
     $path = $dir . DIRECTORY_SEPARATOR . 'test.copy.gif';
     @unlink($path);
     copy(__DIR__ . '/Fixtures/test.gif', $path);
     $file = new File($path);
     @unlink($path);
     try {
         $file->getSize();
         $this->fail('File::getSize should throw an exception.');
     } catch (FileException $e) {
     }
 }
开发者ID:renegare,项目名称:symfony,代码行数:14,代码来源:FileTest.php

示例10: prepareResponse

 private function prepareResponse(File $file, $filename = null)
 {
     $mimeType = $file->getMimeType();
     if ($mimeType == 'application/pdf') {
         $disposition = 'inline';
     } else {
         $disposition = 'attachment';
     }
     $response = new Response();
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-Type', $mimeType);
     $response->headers->set('Content-Disposition', $disposition . '; filename="' . ($filename ? $filename : $file->getFilename()) . '"');
     $response->headers->set('Content-Length', $file->getSize());
     $response->sendHeaders();
     readfile($file);
     return $response;
 }
开发者ID:junjinZ,项目名称:wealthbot,代码行数:17,代码来源:FilesController.php

示例11: VisualAction

 public function VisualAction($document)
 {
     // Generate response
     $response = new Response();
     // Set headers
     $filepath = $this->get('kernel')->getRootDir() . "/uploads/formations_documents/" . $document;
     $oFile = new File($filepath);
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-type', $oFile->getMimeType());
     $response->headers->set('Content-Disposition', 'inline; filepath="' . $oFile->getBasename() . '";');
     $response->headers->set('Content-length', $oFile->getSize());
     // filename
     // Send headers before outputting anything
     $response->sendHeaders();
     $response->setContent(file_get_contents($filepath));
     return $response;
 }
开发者ID:WildCodeSchool,项目名称:partnet,代码行数:17,代码来源:FormationsController.php

示例12: GetFile

 /**
  * @Route("/files/{fileName}")
  * @Method("GET")
  */
 public function GetFile($fileName)
 {
     $finder = new Finder();
     $finder->files()->name($fileName)->in('../data');
     if ($finder->count() == 0) {
         return new Response("File " . $fileName . " not found", 404);
     }
     $iterator = $finder->getIterator();
     $iterator->rewind();
     $file = $iterator->current();
     $oFile = new File(realpath($file));
     $response = new Response(null);
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-type', $oFile->getMimeType());
     $response->headers->set('Content-Disposition', 'attachment; filename="' . $oFile->getBasename() . '";');
     $response->headers->set('Content-length', $oFile->getSize());
     $response->setContent(file_get_contents($oFile));
     return $response;
 }
开发者ID:vgratsilev,项目名称:FileManageAPI,代码行数:23,代码来源:FilesController.php

示例13: beforePrepare

 /**
  * Add parameters Kinvey needs to properly process the file.
  *
  * @param  Guzzle\Common\Event
  * @return void
  */
 public function beforePrepare(Event $event)
 {
     $command = $event['command'];
     $operation = $command->getOperation();
     $client = $command->getClient();
     if ($command->getName() !== 'createEntity') {
         return;
     }
     if ($command['collection'] !== 'files' && $client->getCollectionName() !== 'files') {
         return;
     }
     $file = new File($command['path']);
     $operation->setResponseClass('GovTribe\\LaravelKinvey\\Client\\KinveyFileResponse');
     $operation->addParam(new Parameter(array('name' => 'path', 'type' => 'string', 'default' => $command['path'])));
     $operation->addParam(new Parameter(array('name' => '_public', 'location' => 'json', 'type' => 'boolean', 'default' => isset($command['_public']) ? $command['_public'] : false)));
     $operation->addParam(new Parameter(array('name' => '_filename', 'location' => 'json', 'type' => 'string', 'default' => !isset($command['_filename']) ? $file->getBaseName() : $command['_filename'])));
     $operation->addParam(new Parameter(array('name' => 'size', 'location' => 'json', 'type' => 'integer', 'default' => $file->getSize())));
     $operation->addParam(new Parameter(array('name' => 'mimeType', 'location' => 'json', 'type' => 'string', 'default' => $file->getMimeType())));
 }
开发者ID:tvpsoft,项目名称:laravel-kinvey,代码行数:25,代码来源:KinveyFileMetadataPlugin.php

示例14: getPhotoAction

 /**
  *
  * @param $photo_file
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  */
 public function getPhotoAction($photo_id)
 {
     if (!$this->getUser()) {
         return $this->redirectToRoute('fos_user_security_login');
     }
     $photo_file = $this->get('doctrine')->getRepository('IuchBundle:Photo')->findOneById($photo_id)->getNom();
     // Generate response
     $response = new Response();
     $filepath = $this->get('kernel')->getRootDir() . "/uploads/photos/" . $photo_file;
     $photoFile = new File($filepath);
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-type', $photoFile->getMimeType());
     $response->headers->set('Content-Disposition', 'inline; filepath="' . $photoFile->getBasename() . '";');
     $response->headers->set('Content-length', $photoFile->getSize());
     // Send headers before outputting anything
     $response->sendHeaders();
     $response->setContent(file_get_contents($filepath));
     return $response;
 }
开发者ID:luciemannechez,项目名称:projet-intranet_hopital,代码行数:24,代码来源:PhotoController.php

示例15: createLayout

 protected function createLayout($lang)
 {
     $layout = new Layout($lang, "default-{$lang}");
     $logoPath = $this->getContainer()->get('kernel')->getRootDir() . '/../web/bundles/donatefront/images/logo.png';
     $bgPath = $this->getContainer()->get('kernel')->getRootDir() . '/../web/bundles/donatefront/images/fd-body.jpg';
     $f = new File($logoPath);
     $logo = new UploadedFile($logoPath, 'ulogo.png', $f->getMimeType(), $f->getSize());
     $f = new File($bgPath);
     $bg = new UploadedFile($bgPath, 'ubg.png', $f->getMimeType(), $f->getSize());
     $layout->setLogo($logo);
     $layout->setBackground($bg);
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $repo = $em->getRepository('DonateCoreBundle:Layout');
     $defaultLayout = $repo->findDefaultLayout($lang);
     if (count($defaultLayout) == 0) {
         $layout->setIsDefault(true);
     }
     return $layout;
 }
开发者ID:bco-trey,项目名称:edonate,代码行数:19,代码来源:GenerateBlockCommand.php


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