本文整理汇总了PHP中sfRequest::getFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP sfRequest::getFiles方法的具体用法?PHP sfRequest::getFiles怎么用?PHP sfRequest::getFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfRequest
的用法示例。
在下文中一共展示了sfRequest::getFiles方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeEdit
/**
* Executes edit action
*
* @param sfRequest $request A request object
*/
public function executeEdit($request)
{
$this->forward404If($this->id && !$this->isEditCommunity);
$this->community = Doctrine::getTable('Community')->find($this->id);
if (!$this->community) {
$this->community = new Community();
} else {
if ($request->isMethod('post') && $request->hasParameter('is_delete')) {
$this->redirect('@community_delete');
}
}
$this->communityForm = new CommunityForm($this->community);
$this->communityConfigForm = new CommunityConfigForm(array(), array('community' => $this->community));
$this->communityFileForm = isset($this->enableImage) && $this->enableImage ? new CommunityFileForm(array(), array('community' => $this->community)) : new CommunityFileForm();
if ($request->isMethod('post')) {
$params = $request->getParameter('community');
$params['id'] = $this->id;
$this->communityForm->bind($params);
$this->communityConfigForm->bind($request->getParameter('community_config'));
$this->communityFileForm->bind($request->getParameter('community_file'), $request->getFiles('community_file'));
if ($this->communityForm->isValid() && $this->communityConfigForm->isValid() && $this->communityFileForm->isValid()) {
$this->communityForm->save();
$this->communityConfigForm->save();
$this->communityFileForm->save();
$this->redirect('@community_home?id=' . $this->community->getId());
}
}
}
示例2: execute
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function execute($request)
{
sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
$this->editForm = new dayForm();
$this->day = DaysOrderTable::getInstance()->findOneById($this->getRequest()->getParameter('id'));
if ($this->day) {
$this->editForm->setDefaults($this->day->toArray());
}
if ($this->getRequest()->hasParameter('editDay')) {
$this->editForm->bind($this->getRequest()->getParameter('editDay'), $this->getRequest()->getFiles('editDay'));
if ($this->editForm->isValid()) {
$files = $request->getFiles('editDay');
$i = '';
foreach ($files as $key => $file) {
if ($file['name']) {
$image = new UploadService();
$image->setPath('./uploads/');
$image->setFile($file);
$image->setFileName(md5($file['name'] . date('YmdGis')) . '.' . UploadService::findexts($file['name']));
$image->save();
$this->day['image_name' . $i] = $image->getFileName();
}
$i = 2;
}
$this->day->fromArray(array('day_number' => $this->editForm->getValue('day_number'), 'day_tip' => $this->editForm->getValue('day_tip'), 'day_letter' => $this->editForm->getValue('day_letter')));
$this->day->save();
$this->getUser()->setFlash('editSuccess', true);
$this->redirect(url_for2('default', array('module' => 'days', 'action' => 'index')));
}
}
}
示例3: executeFeedback
/**
* Executes feedback action
*
*/
public function executeFeedback(sfRequest $request)
{
$section = $request->getParameter('section', false);
$this->form = new aFeedbackForm($section);
$this->feedbackSubmittedBy = false;
$this->failed = false;
sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag', 'Url'));
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter('feedback'), $request->getFiles('feedback'));
// $this->form->bind(array_merge($request->getParameter('feedback'), array('captcha' => $request->getParameter('captcha'))), $request->getFiles('feedback'));
if ($this->form->isValid()) {
$feedback = $this->form->getValues();
$feedback['browser'] = $_SERVER['HTTP_USER_AGENT'];
try {
aZendSearch::registerZend();
$mail = new Zend_Mail();
$mail->setBodyText($this->getPartial('feedbackEmailText', array('feedback' => $feedback)))->setFrom($feedback['email'], $feedback['name'])->addTo(sfConfig::get('app_aFeedback_email_auto'))->setSubject($this->form->getValue('subject', 'New aBugReport submission'));
if ($screenshot = $this->form->getValue('screenshot')) {
$mail->createAttachment(file_get_contents($screenshot->getTempName()), $screenshot->getType());
}
$mail->send();
// A new form for a new submission
$this->form = new aFeedbackForm();
} catch (Exception $e) {
$this->logMessage('Request email failed: ' . $e->getMessage(), 'err');
$this->failed = true;
return 'Success';
}
$this->getUser()->setFlash('reportSubmittedBy', $feedback['name']);
$this->redirect($feedback['section']);
}
}
}
示例4: executeApply
public function executeApply(sfRequest $request)
{
//If user is logged in, we're forwarding him to settings page from apply
$this->forwardIf($this->getUser()->isAuthenticated(), 'sfApply', 'settings');
// we're getting default or customized applyForm for the task
if (!($this->form = $this->newForm('applyForm')) instanceof sfGuardUserProfileForm) {
// if the form isn't instance of sfApplyApplyForm, we don't accept it
throw new InvalidArgumentException('The custom apply form should be instance of sfApplyApplyForm');
}
//Code below is used when user is sending his application!
if ($request->isMethod('post')) {
//gathering form request in one array
$formValues = $request->getParameter($this->form->getName());
if (sfConfig::get('app_recaptcha_enabled')) {
$captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'));
//Adding captcha to form array
$formValues = array_merge($formValues, array('captcha' => $captcha));
}
//binding request form parameters with form
$this->form->bind($formValues, $request->getFiles($this->form->getName()));
if ($this->form->isValid()) {
$guid = "n" . self::createGuid();
$this->form->getObject()->setValidate($guid);
$date = new DateTime();
$this->form->getObject()->setValidateAt($date->format('Y-m-d H:i:s'));
$this->form->save();
$confirmation = sfConfig::get('app_sfForkedApply_confirmation');
if ($confirmation['apply']) {
try {
//Extracting object and sending creating verification mail
$profile = $this->form->getObject();
$this->sendVerificationMail($profile);
return 'After';
} catch (Exception $e) {
//Cleaning after possible exception thrown in ::sendVerificationMail() method
$profile = $this->form->getObject();
$user = $profile->getUser();
$profile->delete();
$user->delete();
//We rethrow exception for the dev environment. This catch
//catches other than mailer exception, i18n as well. So developer
//now knows what he's up to.
if (sfContext::getInstance()->getConfiguration()->getEnvironment() === 'dev') {
throw $e;
}
return 'MailerError';
}
} else {
$this->activateUser($this->form->getObject()->getUser());
$this->getUser()->setFlash('notice', "<h3>Поздравляем с успешной регистрацией!</h3>\n\n <p>Теперь Вы можете пользоваться всеми возможностями сервиса:</p>\n <ul>\n <li>Добавлять новые места</li>\n <li>Добавлять отчеты</li>\n <li>Добавлять события</li>\n <li>Открывать обсуждения</li>\n <li>Голосовать комментировать и все подряд</li>\n <li>Заводить друзей</li>\n <li>И многое другое...</li>\n </ul>");
return $this->redirect('@homepage');
}
}
}
}
示例5: executeCreate
/**
* Executes create action
*
* @param sfRequest $request A request object
*/
public function executeCreate($request)
{
$this->form = new BbsCommentForm();
$this->form->getObject()->setMemberId($this->getUser()->getMemberId());
$this->form->getObject()->setBbs($this->bbs);
$this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
if ($this->form->isValid()) {
$this->form->save();
$this->redirect('@bbs_show?id=' . $this->bbs->getId());
}
$this->setTemplate('../../bbs/templates/show');
return sfView::SUCCESS;
}
示例6: executeCreate
/**
* Executes create action
*
* @param sfRequest $request A request object
*/
public function executeCreate($request)
{
$this->forward404Unless($this->communityTopic->isCreatableCommunityTopicComment($this->getUser()->getMemberId()));
$this->form = new CommunityTopicCommentForm();
$this->form->getObject()->setMemberId($this->getUser()->getMemberId());
$this->form->getObject()->setCommunityTopic($this->communityTopic);
$this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
if ($this->form->isValid()) {
$this->form->save();
$this->redirect('@communityTopic_show?id=' . $this->communityTopic->getId());
}
$this->setTemplate('../../communityTopic/templates/show');
return sfView::SUCCESS;
}
示例7: executeCreate
/**
* Executes create action
*
* @param sfRequest $request A request object
*/
public function executeCreate($request)
{
$this->forward404Unless($this->communityEvent->isCreatableCommunityEventComment($this->getUser()->getMemberId()));
$this->form = new CommunityEventCommentForm();
$this->form->getObject()->setMemberId($this->getUser()->getMemberId());
$this->form->getObject()->setCommunityEvent($this->communityEvent);
$this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
if ($this->form->isValid()) {
try {
if (!$request->getParameter('comment')) {
$this->form->getObject()->toggleEventMember($this->getUser()->getMemberId());
}
$this->form->save();
$this->redirect('@communityEvent_show?id=' . $this->communityEvent->getId());
} catch (opCommunityEventMemberAppendableException $e) {
$this->getUser()->setFlash('error', $e->getMessage(), false);
}
}
$this->setTemplate('../../communityEvent/templates/show');
return sfView::SUCCESS;
}
示例8: executeSettings
public function executeSettings(sfRequest $request)
{
// sfApplySettingsForm inherits from sfApplyApplyForm, which
// inherits from sfGuardUserProfile. That minimizes the amount
// of duplication of effort. If you want, you can use a different
// form class. I suggest inheriting from sfApplySettingsForm and
// making further changes after calling parent::configure() from
// your own configure() method.
$profile = $this->getUser()->getProfile();
$this->form = $this->newForm('sfApplySettingsForm', $profile);
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter('sfApplySettings'), $request->getFiles('sfApplySettings'));
if ($this->form->isValid()) {
$this->form->save();
return $this->redirect('people/show?username=' . $this->getUser()->getUsername());
}
}
}
示例9: executeConfigImage
/**
* Executes configImage action
*
* @param sfRequest $request A request object
*/
public function executeConfigImage($request)
{
$options = array('member' => $this->getUser()->getMember());
$this->form = new MemberImageForm(array(), $options);
if ($request->isMethod(sfWebRequest::POST)) {
try {
if (!$this->form->bindAndSave($request->getParameter('member_image'), $request->getFiles('member_image'))) {
$errors = $this->form->getErrorSchema()->getErrors();
if (isset($errors['file'])) {
$error = $errors['file'];
$i18n = $this->getContext()->getI18N();
$this->getUser()->setFlash('error', $i18n->__($error->getMessageFormat(), $error->getArguments()));
}
}
} catch (opRuntimeException $e) {
$this->getUser()->setFlash('error', $e->getMessage());
}
$this->redirect('@member_config_image');
}
}
示例10: executeEditImages
public function executeEditImages(sfRequest $request)
{
$this->forward404Unless(aMediaTools::userHasUploadPrivilege());
// I'd put these in the form class, but I can't seem to access them
// there unless the whole form is valid. I need them as metadata
// to control the form's behavior, so that won't cut it.
// Perhaps I could put them in a second form, since there's
// no actual restriction on multiple form objects inside a
// single HTML form element.
$this->firstPass = $request->getParameter('first_pass');
$active = $request->getParameter('active');
$this->forward404Unless(preg_match("/^\\d+[\\d\\,]*\$/", $active));
$this->active = explode(",", $request->getParameter('active'));
$this->form = new aMediaEditImagesForm($this->active);
$this->form->bind($request->getParameter('a_media_items'), $request->getFiles('a_media_items'));
if ($this->form->isValid()) {
$values = $this->form->getValues();
// This is NOT automatic since this isn't a Doctrine form. http://thatsquality.com/articles/can-the-symfony-forms-framework-be-domesticated-a-simple-todo-list
foreach ($this->form->getEmbeddedForms() as $key => $itemForm) {
$itemForm->updateObject($values[$key]);
$object = $itemForm->getObject();
if ($object->getId()) {
// We're creating new objects only here, but the embedded form
// supports an id for an existing object, which is useful in
// other contexts. Prevent hackers from stuffing in changes
// to media items they don't own.
$this->forward404();
}
// updateObject doesn't handle one-to-many relations, only save() does, and we
// can't do save() in this embedded form, so we need to implement the categories
// relation ourselves
$object->unlink('MediaCategories');
$object->link('MediaCategories', $values[$key]['media_categories_list']);
// Everything except the actual copy which can't succeed
// until the slug is cast in stone
$file = $values[$key]['file'];
$object->preSaveImage($file->getTempName());
$object->save();
$object->saveImage($file->getTempName());
}
return $this->redirect('aMedia/resume');
}
}
示例11: executeSettings
public function executeSettings(sfRequest $request)
{
// sfApplySettingsForm inherits from sfApplyApplyForm, which
// inherits from sfGuardUserProfile. That minimizes the amount
// of duplication of effort. If you want, you can use a different
// form class. I suggest inheriting from sfApplySettingsForm and
// making further changes after calling parent::configure() from
// your own configure() method.
$profile = $this->getUser()->getProfile();
// we're getting default or customized settingsForm for the task
if (!($this->form = $this->newForm('settingsForm', $profile)) instanceof sfGuardUserProfileForm) {
// if the form isn't instance of sfApplySettingsForm, we don't accept it
throw new InvalidArgumentException(sfContext::getInstance()->getI18N()->__('The custom %action% form should be instance of %form%', array('%action%' => 'settings', '%form%' => 'sfApplySettingsForm'), 'sfForkedApply'));
}
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
if ($this->form->isValid()) {
$this->form->save();
return $this->redirect('@homepage');
}
}
}
示例12: executeImportCsv
/**
* Загрузить данные пользователя, AJAX
*/
public function executeImportCsv(sfRequest $request)
{
$csvFile = $request->getFiles('data');
$import = new myImportCsvVkoshelke($csvFile['tmp_name']);
if (!$import->execute($this->getUser()->getUserRecord())) {
$errorMessage = 'Не удалось разобрать CSV';
$this->myLogMessage(__METHOD__, 'fail', $errorMessage, $errorMessage, file_get_contents($csvFile['tmp_name']));
return $this->renderJsonError($errorMessage);
}
$ymlFileName = sprintf("%s/php_%s_%s.yml", sys_get_temp_dir(), __CLASS__, rand(1000000.0, 10000000.0));
try {
file_put_contents($ymlFileName, $import->getYmlData());
Doctrine::loadData($ymlFileName, true);
unlink($ymlFileName);
} catch (Exception $e) {
$errorMessage = 'Импорт не удалось загрузить данные в БД';
$this->myLogMessage(__METHOD__, 'fail', $errorMessage, $errorMessage, file_get_contents($csvFile['tmp_name']));
return $this->renderJsonError($errorMessage);
}
return $this->renderJsonSuccess('Импорт данных успешно завершён');
}