當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。