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


PHP File::setName方法代码示例

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


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

示例1: executeImage

 public function executeImage(sfWebRequest $request)
 {
     $member = $this->getRoute()->getMember();
     if (!$member) {
         return sfView::NONE;
     }
     $community = Doctrine::getTable('Community')->find($request->getParameter('id'));
     if (!$community) {
         return sfView::ERROR;
     }
     $isAdmin = Doctrine::getTable('CommunityMember')->isAdmin($member->getId(), $community->getId());
     if (!$isAdmin || $community->getImageFileName()) {
         return sfView::ERROR;
     }
     $message = $request->getMailMessage();
     if ($images = $message->getImages()) {
         $image = array_shift($images);
         $validator = new opValidatorImageFile();
         $validFile = $validator->clean($image);
         $file = new File();
         $file->setFromValidatedFile($validFile);
         $file->setName('c_' . $community->getId() . '_' . $file->getName());
         $community->setFile($file);
         $community->save();
     }
     return sfView::NONE;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:27,代码来源:actions.class.php

示例2: executeImage

 public function executeImage(sfWebRequest $request)
 {
     $member = $this->getRoute()->getMember();
     if (!$member) {
         return sfView::NONE;
     }
     $message = $request->getMailMessage();
     $images = $message->getImages();
     foreach ($images as $image) {
         $count = $member->getMemberImage()->count();
         if ($count >= 3) {
             return sfView::ERROR;
         }
         $validator = new opValidatorImageFile();
         $validFile = $validator->clean($image);
         $file = new File();
         $file->setFromValidatedFile($validFile);
         $file->setName('m_' . $member->getId() . '_' . $file->getName());
         $memberImage = new MemberImage();
         $memberImage->setMember($member);
         $memberImage->setFile($file);
         if (!$count) {
             $memberImage->setIsPrimary(true);
         }
         $memberImage->save();
     }
     return sfView::NONE;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:28,代码来源:actions.class.php

示例3: save

 public function save()
 {
     $file = new File();
     $file->setFromValidatedFile($this->getValue('file'));
     $file->setName(sprintf('admin_%s_%d', $this->getValue('imageName'), time()));
     return $file->save();
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:7,代码来源:ImageForm.php

示例4: createFromArray

 /**
  * Create a file instance from a file info array ($_FILES)
  * 
  * @param array $fileInfo
  *
  * @return File The created file
  */
 public static function createFromArray(array $fileInfo)
 {
     $file = new File();
     $file->setName(isset($fileInfo['name']) ? $fileInfo['name'] : null);
     $file->setSize(isset($fileInfo['size']) ? $fileInfo['size'] : 0);
     $file->setType(isset($fileInfo['type']) ? $fileInfo['type'] : null);
     $file->setTmpName(isset($fileInfo['tmp_name']) ? $fileInfo['tmp_name'] : null);
     $file->setError(isset($fileInfo['error']) ? $fileInfo['error'] : 0);
     return $file;
 }
开发者ID:timesplinter,项目名称:tsfw-http,代码行数:17,代码来源:File.php

示例5: executePost

 public function executePost(sfWebRequest $request)
 {
     $this->forward400If('' === (string) $request['title'], 'title parameter is not specified.');
     $this->forward400If('' === (string) $request['body'], 'body parameter is not specified.');
     $this->forward400If(!isset($request['public_flag']) || '' === (string) $request['public_flag'], 'public flag is not specified');
     if (isset($request['id']) && '' !== $request['id']) {
         $diary = Doctrine::getTable('Diary')->findOneById($request['id']);
         $this->forward400If(false === $diary, 'the specified diary does not exit.');
         $this->forward400If(false === $diary->isAuthor($this->member->getId()), 'this diary is not yours.');
     } else {
         $diary = new Diary();
         $diary->setMemberId($this->member->getId());
     }
     $diary->setTitle($request['title']);
     $diary->setBody($request['body']);
     $diary->setPublicFlag($request['public_flag']);
     $diary->save();
     $this->diary = $diary;
     for ($i = 1; $i <= 3; $i++) {
         $diaryImage = Doctrine::getTable('DiaryImage')->retrieveByDiaryIdAndNumber($diary->getId(), $i);
         $filename = basename($_FILES['diary_photo_' . $i]['name']);
         if (!is_null($filename) && '' !== $filename) {
             try {
                 $validator = new opValidatorImageFile(array('required' => false));
                 $validFile = $validator->clean($_FILES['diary_photo_' . $i]);
             } catch (Exception $e) {
                 $this->forward400($e->getMessage());
             }
             $f = new File();
             $f->setFromValidatedFile($validFile);
             $f->setName(hash('md5', uniqid((string) $i) . $filename));
             if ($stream = fopen($_FILES['diary_photo_' . $i]['tmp_name'], 'r')) {
                 if (!is_null($diaryImage)) {
                     $diaryImage->delete();
                 }
                 $bin = new FileBin();
                 $bin->setBin(stream_get_contents($stream));
                 $f->setFileBin($bin);
                 $f->save();
                 $di = new DiaryImage();
                 $di->setDiaryId($diary->getId());
                 $di->setFileId($f->getId());
                 $di->setNumber($i);
                 $di->save();
                 $diary->updateHasImages();
             } else {
                 $this->forward400(__('Failed to write file to disk.'));
             }
         }
         $deleteCheck = $request['diary_photo_' . $i . '_photo_delete'];
         if ('on' === $deleteCheck && !is_null($diaryImage)) {
             $diaryImage->delete();
         }
     }
 }
开发者ID:meruto,项目名称:opDiaryPlugin,代码行数:55,代码来源:actions.class.php

示例6: getFile

 public function getFile($isCreate = false)
 {
     if ($this->hasFile()) {
         return $this->file;
     }
     if ($isCreate) {
         $file = new File();
         $file->setName(self::FILE_NAME);
         $file->setFileBin(new FileBin());
         return $file;
     }
     return false;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:13,代码来源:opGoogleOAuthJson.class.php

示例7: save

 public function save()
 {
     $file = new File();
     $file->setFromValidatedFile($this->getValue('file'));
     $file->setName('b_' . $file->getName());
     if ($this->isNew()) {
         $bannerImage = new BannerImage();
     } else {
         $bannerImage = $this->getObject();
     }
     $bannerImage->setFile($file);
     $bannerImage->setUrl($this->getValue('url'));
     $bannerImage->setName($this->getValue('name'));
     return $bannerImage->save();
 }
开发者ID:phenom,项目名称:OpenPNE3,代码行数:15,代码来源:BannerImageForm.class.php

示例8: testGetFile

 function testGetFile()
 {
     if (!$this->bucket) {
         $this->fail('Cannot continue without valid bucket');
     }
     $file = new File();
     $file->setName('S3ConnectionTest.txt');
     try {
         $size = $this->bucket->getFileSize($file);
     } catch (Exception $e) {
         $error = true;
         echo $e->getMessage();
     }
     $this->assertFalse(isset($error));
 }
开发者ID:helpfulrobot,项目名称:edlinklater-silverstripe-cloudassets-s3,代码行数:15,代码来源:CloudAssetsS3Test.php

示例9: save

 public function save()
 {
     $count = $this->member->getMemberImage()->count();
     if ($count >= 3) {
         throw new opRuntimeException('Cannot add an image any more.');
     }
     $file = new File();
     $file->setFromValidatedFile($this->getValue('file'));
     $file->setName('m_' . $this->member->getId() . '_' . $file->getName());
     $memberImage = new MemberImage();
     $memberImage->setMember($this->member);
     $memberImage->setFile($file);
     if (!$count) {
         $memberImage->setIsPrimary(true);
     }
     return $memberImage->save();
 }
开发者ID:Kazuhiro-Murota,项目名称:OpenPNE3,代码行数:17,代码来源:MemberImageForm.class.php

示例10: control

 public function control()
 {
     $this->redirectToSternIndiaEndPoint();
     $config = Config::getInstance();
     if (isset($_POST['upload']) && $_POST['upload'] == 'Upload') {
         $target_dir = new FileSystem('upload/');
         $file = new File('foo', $target_dir);
         $name = date('D_d_m_Y_H_m_s_');
         $name = $name . $file->getName();
         $file->setName($name);
         $config = Config::getInstance();
         $file->addValidations(array(new Mimetype($config->getMimeTypes()), new Size('5M')));
         $data = array('name' => $file->getNameWithExtension(), 'extension' => $file->getExtension(), 'mime' => $file->getMimetype(), 'size' => $file->getSize(), 'md5' => $file->getMd5());
         try {
             // /Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
             $file->upload();
             //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
         } catch (Exception $e) {
             $errors = $file->getErrors();
         }
         $csvReader = new CSVReader();
         $destinationFile = $target_dir->directory . $file->getNameWithExtension();
         $data = $csvReader->parse_file($destinationFile);
         //$country= DAOFactory::getDAO('LocationDAO');
         foreach ($data as $loc_arr) {
             Utils::processLocation($loc_arr);
         }
         //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__);
         $target_dir = "uploads/";
         $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
         $uploadOk = 1;
         $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
         // Check if image file is a actual image or fake image
         if (isset($_POST["submit"])) {
             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
             if ($check !== false) {
                 echo "File is an image - " . $check["mime"] . ".";
                 $uploadOk = 1;
             } else {
                 echo "File is not an image.";
                 $uploadOk = 0;
             }
         }
     }
     return $this->generateView();
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:46,代码来源:class.FileUploadController.php

示例11: toFile

 public function toFile($filename = "file", $folder = "PDF")
 {
     $filename = $this->addFileExt($filename);
     $filedir = ASSETS_DIR . "/{$folder}/{$filename}";
     $filepath = ASSETS_PATH . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename;
     $folder = Folder::find_or_make($folder);
     $output = $this->output();
     if ($fh = fopen($filepath, 'w')) {
         fwrite($fh, $output);
         fclose($fh);
     }
     $file = new File();
     $file->setName($filename);
     $file->Filename = $filedir;
     $file->ParentID = $folder->ID;
     $file->write();
     return $file;
 }
开发者ID:wakes,项目名称:ssdompdf,代码行数:18,代码来源:SS_DOMPDF.php

示例12: save

 public function save()
 {
     if ($this->getValue('file')) {
         if ($this->community->getFile()) {
             $this->community->getFile()->delete();
         }
         $file = new File();
         $file->setFromValidatedFile($this->getValue('file'));
         $file->setName('c_' . $this->community->getId() . '_' . $file->getName());
         $this->community->setFile($file);
     } elseif ($this->getValue('file_delete')) {
         $this->community->getFile()->delete();
         $this->community->setFile(null);
     } else {
         return;
     }
     $this->community->save();
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:18,代码来源:CommunityFileForm.class.php

示例13: updateObject

 public function updateObject($values = null)
 {
     if (is_null($values)) {
         $values = $this->getValues();
     }
     $image = null;
     if (array_key_exists('image', $values)) {
         $image = $values['image'];
         unset($values['image']);
     }
     $obj = parent::updateObject($values);
     if ($image instanceof sfValidatedFile) {
         unset($obj->Image);
         $file = new File();
         $file->setFromValidatedFile($image);
         $file->setName('oauth_' . $obj->getId() . '_' . $file->getName());
         $obj->setImage($file);
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:19,代码来源:OAuthConsumerInformationForm.class.php

示例14: savePchFileFromRawData

 public function savePchFileFromRawData(&$pchData, Doctrine_Connection $conn = null)
 {
     if ($this->getPchFileId()) {
         $pchFile = $this->getPchFile();
     } else {
         $pchFile = new File();
     }
     $pchFile->setType('image/pch');
     $pchFile->setName('cccc_' . time() . '_pch');
     $pchFile->save($conn);
     $fileBin = $pchFile->getFileBin();
     if (!$fileBin) {
         $fileBin = new FileBin();
         $fileBin->setFileId($pchFile->getId);
     }
     $fileBin->setBin($pchData);
     $fileBin->save($conn);
     $this->setPchFileId($pchFile->getId());
 }
开发者ID:nothan,项目名称:opCCCCPlugin,代码行数:19,代码来源:PluginCcccImage.class.php

示例15: setImage

 public function setImage($data)
 {
     $form = new MemberImageForm(array(), array('member' => $this->member));
     $imageUri = '';
     $pathList = array('media/image/default', 'media/image/aspect11', 'media/image/aspect43', 'media/image/aspect34');
     foreach ($pathList as $v) {
         $img = $this->getValue($data, $v);
         if ($img) {
             $imageUri = $img;
             break;
         }
     }
     if ($imageUri) {
         $client = new Zend_Http_Client(array_shift($imageUri));
         $response = $client->request();
         if (!$response->isError()) {
             $type = $response->getHeader('Content-type');
             if (is_array($type)) {
                 $type = array_shift($type);
             }
             $tmppath = tempnam(sys_get_temp_dir(), 'IMG');
             $fh = fopen($tmppath, 'w');
             fwrite($fh, $response->getBody());
             fclose($fh);
             $image = array('tmp_name' => $tmppath, 'type' => $type);
             $validator = new opValidatorImageFile();
             $validFile = $validator->clean($image);
             $file = new File();
             $file->setFromValidatedFile($validFile);
             $file->setName('m_' . $this->member->getId() . '_' . $file->getName());
             $memberImage = new MemberImage();
             $memberImage->setMember($this->member);
             $memberImage->setFile($file);
             $memberImage->setIsPrimary(true);
             $memberImage->save();
         }
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:38,代码来源:opOpenIDAxProfileImport.class.php


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