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


PHP Upload::create方法代码示例

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


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

示例1: get

 public function get($id, $request)
 {
     if (UserChannel::find($id)->belongToUser(Session::get()->id)) {
         $uploadId = Upload::generateId(6);
         Upload::create(array('id' => $uploadId, 'channel_id' => $id, 'video_id' => Video::generateId(6), 'expire' => Utils::tps() + 86400));
         $data = array();
         $data['currentPageTitle'] = 'Mettre en ligne';
         $data['uploadId'] = $uploadId;
         $data['thumbnail'] = Config::getValue_('default-thumbnail');
         $data['channelId'] = $id;
         $data['currentPage'] = 'upload';
         //$data['predefined_descriptions'] = PredefinedDescription::getDescriptionByChannelsids($id);
         return new ViewResponse('upload/upload', $data);
     } else {
         return new RedirectResponse(WEBROOT . 'upload');
     }
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:17,代码来源:upload_controller.php

示例2: __construct

 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     $fields = new FieldList($Nickname = TextField::create('Nickname')->setTitle(_t('Member.NICKNAME', 'Member.NICKNAME')), $Location = BootstrapGeoLocationField::create('Location')->setTitle(_t('Member.LOCATION', 'Member.LOCATION')), $About = TextareaField::create('About')->setTitle(_t('DonatorProfile.ABOUT', 'DonatorProfile.ABOUT'))->setPlaceholder(_t('DonatorProfile.ABOUTDESCRIPTION', 'DonatorProfile.ABOUTDESCRIPTION')), $Active = CheckboxField::create('Active')->setTitle(_t('Member.ACTIVE', 'Member.ACTIVE')), $Avatar = BootstrapFileField::create('Avatar')->setTitle(_t('Member.AVATAR', 'Member.AVATAR')));
     $Location->setRightTitle(_t('Member.LOCATIONDESCRIPTION', 'Member.LOCATIONDESCRIPTION'));
     $About->setRightTitle(_t('DonatorProfile.ABOUTDESCRIPTION', 'DonatorProfile.ABOUTDESCRIPTION'));
     // Upload Parameters
     $exts = array('jpg', 'jpeg', 'gif', 'png');
     $validator = new Upload_Validator();
     $validator->setAllowedExtensions($exts);
     $validator->setAllowedMaxFileSize(5000000);
     $upload = Upload::create();
     $upload->setValidator($validator);
     // Avatar Upload Folder
     $Avatar->setFolderName("Uploads/Members/" . Member::currentUser()->ID . "/Avatars");
     $Avatar->setUpload($upload);
     $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doSave')->setTitle(_t('HostelEditForm.SAVEBUTTON', 'HostelEditForm.SAVEBUTTON')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Nickname", "Location", "About"));
     $this->loadDataFrom(Member::currentUser());
 }
开发者ID:andrelohmann,项目名称:roof-for-refugees.org,代码行数:19,代码来源:DonatorEditForm.php

示例3: __construct

 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     $fields = new FieldList($Version = BootstrapSemVerField::create('Version')->setTitle(_t('BoxVersion.VERSION', 'BoxVersion.VERSION')), $Description = TextareaField::create('Description')->setTitle(_t('Box.DESCRIPTION', 'Box.DESCRIPTION')), $File = new BootstrapUploadField('File', _t('Box.FILE', 'Box.FILE')), $BoxID = HiddenField::create('BoxID'));
     $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doAdd')->setTitle(_t('BoxAddForm.DOADD', 'BoxAddForm.DOADD')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Version", "Description", "File", "BoxID"));
     if (isset($GLOBALS['BoxID'])) {
         $Box = Box::get()->byID($GLOBALS['BoxID']);
         $BoxID->setValue($Box->ID);
         $Description->setValue($Box->Description);
         $File->setFolderName("Uploads/Boxes/" . $Box->Slug);
     }
     // Upload Parameters
     $exts = array('box');
     $validator = new Upload_Validator();
     $validator->setAllowedExtensions($exts);
     //$validator->setAllowedMaxFileSize(5000000);
     $upload = Upload::create();
     $upload->setValidator($validator);
     $File->setUpload($upload);
     $this->loadDataFrom(singleton('BoxProvider'));
 }
开发者ID:andrelohmann,项目名称:vagrant-cloud,代码行数:21,代码来源:BoxAddVersionForm.php

示例4: __construct

 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     $fields = new FieldList($Nickname = TextField::create('Nickname')->setTitle(_t('Member.NICKNAME', 'Member.NICKNAME')), $Location = BootstrapGeoLocationField::create('Location')->setTitle(_t('Member.LOCATION', 'Member.LOCATION')), $Adults = DropdownField::create('Adults')->setTitle(_t('RefugeeProfile.ADULTS', 'RefugeeProfile.ADULTS'))->setSource(Config::inst()->get('Member', 'people_sum')), $Children = DropdownField::create('Children')->setTitle(_t('RefugeeProfile.CHILDREN', 'RefugeeProfile.CHILDREN'))->setSource(Config::inst()->get('Member', 'people_sum')), $Baby = CheckboxField::create('Baby')->setTitle(_t('RefugeeProfile.BABY', 'RefugeeProfile.BABY')), $About = TextareaField::create('About')->setTitle(_t('RefugeeProfile.ABOUT', 'RefugeeProfile.ABOUT'))->setPlaceholder(_t('RefugeeProfile.ABOUTDESCRIPTION', 'RefugeeProfile.ABOUTDESCRIPTION')), $Active = CheckboxField::create('Active')->setTitle(_t('Member.ACTIVE', 'Member.ACTIVE')), $Avatar = BootstrapFileField::create('Avatar')->setTitle(_t('Member.AVATAR', 'Member.AVATAR')));
     $Location->setRightTitle(_t('Member.LOCATIONDESCRIPTION', 'Member.LOCATIONDESCRIPTION'));
     $Adults->setRightTitle(_t('RefugeeProfile.ADULTSDESCRIPTION', 'RefugeeProfile.ADULTSDESCRIPTION'));
     $Children->setRightTitle(_t('RefugeeProfile.CHILDRENDESCRIPTION', 'RefugeeProfile.CHILDRENDESCRIPTION'));
     $Baby->setRightTitle(_t('RefugeeProfile.BABYDESCRIPTION', 'RefugeeProfile.BABYDESCRIPTION'));
     $About->setRightTitle(_t('RefugeeProfile.ABOUTDESCRIPTION', 'RefugeeProfile.ABOUTDESCRIPTION'));
     // Upload Parameters
     $exts = array('jpg', 'jpeg', 'gif', 'png');
     $validator = new Upload_Validator();
     $validator->setAllowedExtensions($exts);
     $validator->setAllowedMaxFileSize(5000000);
     $upload = Upload::create();
     $upload->setValidator($validator);
     // Avatar Upload Folder
     $Avatar->setFolderName("Uploads/Members/" . Member::currentUser()->ID . "/Avatars");
     $Avatar->setUpload($upload);
     $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doSave')->setTitle(_t('RefugeeEditForm.SAVEBUTTON', 'RefugeeEditForm.SAVEBUTTON')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Nickname", "Location", "Adults", "Children", "About"));
     $this->loadDataFrom(Member::currentUser());
 }
开发者ID:andrelohmann,项目名称:roof-for-refugees.org,代码行数:22,代码来源:RefugeeEditForm.php

示例5: __construct

 /**
  * Create a new file field.
  *
  * @param string $name The internal field name, passed to forms.
  * @param string $title The field label.
  * @param int $value The value of the field.
  */
 public function __construct($name, $title = null, $value = null)
 {
     $this->upload = Upload::create();
     parent::__construct($name, $title, $value);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:12,代码来源:FileField.php

示例6: doPostMessageForm

 /**
  * Post a message to the forum. This method is called whenever you want to make a
  * new post or edit an existing post on the forum
  *
  * @param Array - Data
  * @param Form - Submitted Form
  */
 function doPostMessageForm($data, $form)
 {
     $member = Member::currentUser();
     $content = isset($data['Content']) ? $this->filterLanguage($data["Content"]) : "";
     $title = isset($data['Title']) ? $this->filterLanguage($data["Title"]) : false;
     // If a thread id is passed append the post to the thread. Otherwise create
     // a new thread
     $thread = false;
     if (isset($data['ThreadID'])) {
         $thread = DataObject::get_by_id('ForumThread', $data['ThreadID']);
     }
     // If this is a simple edit the post then handle it here. Look up the correct post,
     // make sure we have edit rights to it then update the post
     $post = false;
     if (isset($data['ID'])) {
         $post = DataObject::get_by_id('Post', $data['ID']);
         if ($post && $post->isFirstPost()) {
             if ($title) {
                 $thread->Title = $title;
             }
         }
     }
     // Check permissions
     $messageSet = array('default' => _t('Forum.LOGINTOPOST', 'You\'ll need to login before you can post to that forum. Please do so below.'), 'alreadyLoggedIn' => _t('Forum.NOPOSTPERMISSION', 'I\'m sorry, but you do not have permission post to this forum.'), 'logInAgain' => _t('Forum.LOGINTOPOSTAGAIN', 'You have been logged out of the forums.  If you would like to log in again to post, enter a username and password below.'));
     // Creating new thread
     if (!$thread && !$this->canPost()) {
         Security::permissionFailure($this, $messageSet);
         return false;
     }
     // Replying to existing thread
     if ($thread && !$post && !$thread->canPost()) {
         Security::permissionFailure($this, $messageSet);
         return false;
     }
     // Editing existing post
     if ($thread && $post && !$post->canEdit()) {
         Security::permissionFailure($this, $messageSet);
         return false;
     }
     if (!$thread) {
         $thread = new ForumThread();
         $thread->ForumID = $this->ID;
         if ($title) {
             $thread->Title = $title;
         }
         $starting_thread = true;
     }
     // Upload and Save all files attached to the field
     // Attachment will always be blank, If they had an image it will be at least in Attachment-0
     //$attachments = new DataObjectSet();
     $attachments = new ArrayList();
     if (!empty($data['Attachment-0']) && !empty($data['Attachment-0']['tmp_name'])) {
         $id = 0;
         //
         // @todo this only supports ajax uploads. Needs to change the key (to simply Attachment).
         //
         while (isset($data['Attachment-' . $id])) {
             $image = $data['Attachment-' . $id];
             if ($image && !empty($image['tmp_name'])) {
                 $file = Post_Attachment::create();
                 $file->OwnerID = Member::currentUserID();
                 $folder = Config::inst()->get('ForumHolder', 'attachments_folder');
                 try {
                     $upload = Upload::create()->loadIntoFile($image, $file, $folder);
                     $file->write();
                     $attachments->push($file);
                 } catch (ValidationException $e) {
                     $message = _t('Forum.UPLOADVALIDATIONFAIL', 'Unallowed file uploaded. Please only upload files of the following: ');
                     $message .= implode(', ', Config::inst()->get('File', 'allowed_extensions'));
                     $form->addErrorMessage('Attachment', $message, 'bad');
                     Session::set("FormInfo.Form_PostMessageForm.data", $data);
                     return $this->redirectBack();
                 }
             }
             $id++;
         }
     }
     // from now on the user has the correct permissions. save the current thread settings
     $thread->write();
     if (!$post || !$post->canEdit()) {
         $post = new Post();
         $post->AuthorID = $member ? $member->ID : 0;
         $post->ThreadID = $thread->ID;
     }
     $post->ForumID = $thread->ForumID;
     $post->Content = $content;
     $post->write();
     if ($attachments) {
         foreach ($attachments as $attachment) {
             $attachment->PostID = $post->ID;
             $attachment->write();
         }
     }
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:silverstripe-forum,代码行数:101,代码来源:Forum.php


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