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


PHP File::getBasename方法代码示例

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


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

示例1: getFilename

 /**
  * Calculate the filename of the resultant file or version.
  *
  * @param File        $original The original file
  * @param string|null $version  The name of the version, or null
  *
  * @return string The resultant filename
  */
 public function getFilename(File $original, $version = null)
 {
     if (is_null($version)) {
         return $original->getBasename();
     }
     $extension = $original->getExtension();
     $base = $original->getBasename($extension);
     return $base . $version . '.' . $extension;
 }
开发者ID:clarkf,项目名称:hitch,代码行数:17,代码来源:Uploader.php

示例2: updateImage

 /**
  * @param \Exolnet\Image\Image                        $image
  * @param \Symfony\Component\HttpFoundation\File\File $file
  */
 public function updateImage(Image $image, File $file)
 {
     $this->destroy($image);
     $fileName = $image->getId() . '-' . Str::slug($file->getBasename()) . '.' . $file->guessExtension();
     $image->setFilename($fileName);
     $image->save();
     $this->store($image, $file);
 }
开发者ID:eXolnet,项目名称:laravel-image,代码行数:12,代码来源:ImageService.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: __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

示例5: 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

示例6: 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

示例7: uploadByPath

 /**
  * Upload local file to storage
  *
  * @access public
  * @param  mixed  $pathname
  * @param  bool   $unlinkAfterUpload (default: true)
  * @return string
  */
 public function uploadByPath($pathname, $unlinkAfterUpload = true)
 {
     $file = new File($pathname);
     $filename = $file->getBasename();
     $fileMimeType = $file->getMimeType();
     if ($this->allowedTypes && !in_array($fileMimeType, $this->allowedTypes)) {
         throw new \InvalidArgumentException(sprintf('Files of type %s are not allowed.', $fileMimeType));
     }
     $adapter = $this->filesystem->getAdapter();
     if (!$adapter instanceof Local) {
         $adapter->setMetadata($filename, ['contentType' => $fileMimeType]);
     }
     $adapter->write($filename, file_get_contents($file->getPathname()));
     if ($unlinkAfterUpload) {
         unlink($file->getPathname());
     }
     return $filename;
 }
开发者ID:intaro,项目名称:file-uploader-bundle,代码行数:26,代码来源:FileUploader.php

示例8: 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

示例9: 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

示例10: PictureOrganismeAction

 public function PictureOrganismeAction($picture)
 {
     if (!$this->getUser()) {
         return $this->redirectToRoute('fos_user_security_login');
     }
     // Generate response
     $response = new Response();
     // Set headers
     $filepath = $this->get('kernel')->getRootDir() . "/uploads/organismes_pictures/" . $picture;
     $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,代码行数:20,代码来源:OrganismeController.php

示例11: setImporters

 /**
  * Inject the rootPath.
  *
  * @param File  $template
  * @param array $data
  */
 private function setImporters(File $template, User $owner)
 {
     foreach ($this->listImporters as $importer) {
         $importer->setRootPath($this->templateDirectory . DIRECTORY_SEPARATOR . $template->getBasename());
         $importer->setOwner($owner);
         $data = $this->container->get('claroline.manager.workspace_manager')->getTemplateData($template);
         $importer->setConfiguration($data);
         $importer->setListImporters($this->listImporters);
         if ($this->logger) {
             $importer->setLogger($this->logger);
         }
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:19,代码来源:TransferManager.php

示例12: removeTemplate

 public function removeTemplate(File $file)
 {
     $fileName = $file->getBasename();
     $extractPath = $this->templateDirectory . DIRECTORY_SEPARATOR . $fileName;
     $fs = new FileSystem();
     $fs->remove($extractPath);
 }
开发者ID:claroline,项目名称:distribution,代码行数:7,代码来源:WorkspaceManager.php

示例13: copyToRemote

 /**
  * @param File        $localFile
  * @param string      $remotePath
  * @param string|null $filename
  *
  * @return bool
  */
 private function copyToRemote(File $localFile, $remotePath, $filename = null)
 {
     $filename = $filename ? $filename : $localFile->getBasename();
     $success = $this->storage->put($remotePath . '/' . $filename, file_get_contents($localFile->getPathname()));
     return $success;
 }
开发者ID:stickableapp,项目名称:stickable-api,代码行数:13,代码来源:ImageProcessor.php

示例14: transferFile

 public function transferFile()
 {
     //        dump($_POST['tf_file']);
     //        dump($_POST['from_connection']);
     //        dump($_POST['to_connection_name']);
     //        dump($_POST['to_path']);
     $proObj = new Provider($_POST['from_connection']);
     $filename = $proObj->downloadFile($_POST['tf_file'], 'temp');
     $proObj->deleteFile($_POST['tf_file']);
     $proObj = new Provider($_POST['to_connection_name']);
     $objfile = new File($filename);
     $file = array('name' => $objfile->getBasename(), 'type' => $objfile->getMimeType(), 'tmp_name' => $filename, 'error' => 0, 'size' => $objfile->getSize());
     $proObj->uploadFile($file, $_POST['to_path']);
     readfile($filename);
     unlink($filename);
 }
开发者ID:noxfate,项目名称:gathercloud,代码行数:16,代码来源:HomeController.php

示例15: up

 /**
  * @param Schema $schema
  *
  * @throws SkipMigrationException
  */
 public function up(Schema $schema)
 {
     /*
      * Migration is not critical
      * Old format for storing image files to the new format
      *
      * Old format(date added image):
      *    media/{Y}/{m}/
      *
      * New Format(date added item):
      *    media/{Y}/{m}/{d}/{His}/
      */
     // move covers
     $items = $this->connection->fetchAll('
         SELECT
             `id`,
             `cover`,
             `date_add`
         FROM
             `item`
         WHERE
             `cover` IS NOT NULL AND
             `cover` != "" AND
             `cover`  NOT LIKE "example/%"');
     foreach ($items as $item) {
         $path = date('Y/m/d/His/', strtotime($item['date_add']));
         $file = new File($this->media_dir . $item['cover']);
         $file->move($this->media_dir . $path);
         $this->addSql('
             UPDATE
                 `item`
             SET
                 `cover` = ?
             WHERE
                 `id` = ?', [$path . $file->getBasename(), $item['id']]);
     }
     // move images
     $images = $this->connection->fetchAll('
         SELECT
             im.`id`,
             im.`source`,
             i.`date_add`
         FROM
             `item` AS `i`
         INNER JOIN
             `image` AS `im`
             ON
                 im.`item` = i.`id`');
     foreach ($images as $image) {
         $path = date('Y/m/d/His/', strtotime($image['date_add']));
         $file = new File($this->media_dir . $image['source']);
         $file->move($this->media_dir . $path);
         $this->addSql('
             UPDATE
                 `image`
             SET
                 `source` = ?
             WHERE
                 `id` = ?', [$path . $file->getBasename(), $image['id']]);
     }
     // skip if no data
     $this->skipIf(!($items && $images), 'No data to migrate');
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:68,代码来源:Version20131015113854_ChangeImagePaths.php


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