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


PHP waRequest::file方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $product_id = $this->get('product_id', true);
     $this->getProduct($product_id);
     $file = waRequest::file('file');
     $image = $file->waImage();
     if ($file->uploaded()) {
         $data = array('product_id' => $product_id, 'upload_datetime' => date('Y-m-d H:i:s'), 'width' => $image->width, 'height' => $image->height, 'size' => $file->size, 'original_filename' => basename($file->name), 'ext' => $file->extension, 'description' => waRequest::post('description'));
         $product_images_model = new shopProductImagesModel();
         $image_id = $data['id'] = $product_images_model->add($data);
         if (!$image_id) {
             throw new waAPIException('server_error', 500);
         }
         /**
          * @var shopConfig $config
          */
         $config = wa('shop')->getConfig();
         $image_path = shopImage::getPath($data);
         if (file_exists($image_path) && !is_writable($image_path) || !file_exists($image_path) && !waFiles::create($image_path)) {
             $product_images_model->deleteById($image_id);
             throw new waAPIException(sprintf("The insufficient file write permissions for the %s folder.", substr($image_path, strlen($config->getRootPath()))));
         }
         $file->moveTo($image_path);
         unset($image);
         shopImage::generateThumbs($data, $config->getImageSizes());
         $method = new shopProductImagesGetInfoMethod();
         $_GET['id'] = $image_id;
         $this->response = $method->getResponse(true);
     } else {
         throw new waAPIException('server_error', $file->error);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:32,代码来源:shop.product.images.add.method.php

示例2: execute

 public function execute()
 {
     $plugin_id = waRequest::get('id');
     if (!$plugin_id) {
         throw new waException(_ws("Can't save plugin settings: unknown plugin id"));
     }
     $namespace = 'photos_' . $plugin_id;
     /**
      * @var photosPlugin $plugin
      */
     $plugin = waSystem::getInstance()->getPlugin($plugin_id);
     $settings = (array) $this->getRequest()->post($namespace);
     $files = waRequest::file($namespace);
     $settings_defenitions = $plugin->getSettings();
     foreach ($files as $name => $file) {
         if (isset($settings_defenitions[$name])) {
             $settings[$name] = $file;
         }
     }
     try {
         $plugin->saveSettings($settings);
     } catch (Exception $e) {
         $this->errors = $e->getMessage();
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:25,代码来源:photosPluginsSave.controller.php

示例3: saveAction

 public function saveAction()
 {
     $plugin_id = waRequest::get('id');
     if (!$plugin_id) {
         throw new waException(_ws("Can't save plugin settings: unknown plugin id"));
     }
     $namespace = $this->getAppId() . '_' . $plugin_id;
     /**
      * @var shopPlugin $plugin
      */
     $plugin = waSystem::getInstance()->getPlugin($plugin_id);
     $settings = (array) $this->getRequest()->post($namespace);
     $files = waRequest::file($namespace);
     $settings_defenitions = $plugin->getSettings();
     foreach ($files as $name => $file) {
         if (isset($settings_defenitions[$name])) {
             $settings[$name] = $file;
         }
     }
     try {
         $response = $plugin->saveSettings($settings);
         $response['message'] = _w('Saved');
         $this->displayJson($response);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         $this->displayJson(array(), $e->getMessage());
     }
 }
开发者ID:Rupreht,项目名称:webasyst-framework,代码行数:28,代码来源:waPlugins.actions.php

示例4: execute

 public function execute()
 {
     $this->response['files'] = array();
     $this->getStorage()->close();
     if (waRequest::server('HTTP_X_FILENAME')) {
         $name = waRequest::server('HTTP_X_FILE_NAME');
         $size = waRequest::server('HTTP_X_FILE_SIZE');
         $file_path = wa()->getTempPath('shop/upload/') . $name;
         $append_file = is_file($file_path) && $size > filesize($file_path);
         clearstatcache();
         file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
         $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0));
         try {
             $this->response['files'][] = $this->save($file);
         } catch (Exception $e) {
             $this->response['files'][] = array('error' => $e->getMessage());
         }
     } else {
         $files = waRequest::file($this->name);
         foreach ($files as $file) {
             if ($file->error_code != UPLOAD_ERR_OK) {
                 $this->response['files'][] = array('error' => $file->error);
             } else {
                 try {
                     $this->response['files'][] = $this->save($file);
                 } catch (Exception $e) {
                     $this->response['files'][] = array('name' => $file->name, 'error' => $e->getMessage());
                 }
             }
         }
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:32,代码来源:shopUploadController.class.php

示例5: execute

 public function execute()
 {
     if (!$this->getUser()->getRights('shop', 'settings')) {
         throw new waException(_w('Access denied'));
     }
     $plugin_id = waRequest::get('id');
     if (!$plugin_id) {
         throw new waException(_ws("Can't save plugin settings: unknown plugin id"));
     }
     $namespace = 'shop_' . $plugin_id;
     /**
      * @var shopPlugin $plugin
      */
     $plugin = waSystem::getInstance()->getPlugin($plugin_id);
     $settings = (array) $this->getRequest()->post($namespace);
     $files = waRequest::file($namespace);
     $settings_defenitions = $plugin->getSettings();
     foreach ($files as $name => $file) {
         if (isset($settings_defenitions[$name])) {
             $settings[$name] = $file;
         }
     }
     try {
         $this->response = $plugin->saveSettings($settings);
         $this->response['message'] = _w('Saved');
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:29,代码来源:shopPluginsSave.controller.php

示例6: process

 protected function process()
 {
     $f = waRequest::file('file');
     $this->name = $f->name;
     if ($this->processFile($f)) {
         $this->response = wa()->getDataUrl('img/' . $this->name, true, null, true);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:8,代码来源:blogPostImage.controller.php

示例7: execute

 public function execute()
 {
     if (!$this->getRights('upload')) {
         throw new waRightsException(_w("You don't have sufficient access rights"));
     }
     $this->response['files'] = array();
     $this->model = new photosPhotoModel();
     $album_rights_model = new photosAlbumRightsModel();
     // rights for photos
     $this->status = waRequest::post('status', 0, 'int');
     $this->groups = waRequest::post('groups', array(), waRequest::TYPE_ARRAY_INT);
     if (!$this->groups) {
         $this->status = -1;
         // only author have access to this photo
         $this->groups = array(-$this->getUser()->getId());
     }
     // work with album
     $this->album_id = waRequest::post('album_id');
     $this->album_id = (int) $this->album_id;
     if ($this->album_id > 0 && !$album_rights_model->checkRights($this->album_id, true)) {
         $this->response['files'][] = array('error' => _w("You don't have sufficient access rights"));
         return;
     }
     $this->getStorage()->close();
     if (waRequest::server('HTTP_X_FILE_NAME')) {
         $name = waRequest::server('HTTP_X_FILE_NAME');
         $size = waRequest::server('HTTP_X_FILE_SIZE');
         $file_path = wa()->getTempPath('photos/upload/') . $name;
         $append_file = is_file($file_path) && $size > filesize($file_path);
         clearstatcache();
         file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
         $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0));
         try {
             $this->response['files'][] = $this->save($file);
         } catch (Exception $e) {
             $this->response['files'][] = array('error' => $e->getMessage());
         }
     } else {
         $files = waRequest::file('files');
         foreach ($files as $file) {
             if ($file->error_code != UPLOAD_ERR_OK) {
                 $this->response['files'][] = array('error' => $file->error);
             } else {
                 try {
                     $this->response['files'][] = $this->save($file);
                 } catch (Exception $e) {
                     $this->response['files'][] = array('name' => $file->name, 'error' => $e->getMessage());
                 }
             }
         }
     }
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:52,代码来源:photosUploadPhoto.controller.php

示例8: execute

 public function execute()
 {
     try {
         $file = waRequest::file('files');
         if ($file->uploaded()) {
             $filepath = wa()->getCachePath('plugins/discountcards/import-discountcards.csv', 'shop');
             $file->moveTo($filepath);
         } else {
             throw new waException('Ошибка загрузки файла');
         }
     } catch (Exception $ex) {
         $this->setError($ex->getMessage());
     }
 }
开发者ID:klxqz,项目名称:discountcards,代码行数:14,代码来源:shopDiscountcardsPluginUpload.controller.php

示例9: sendForm

 public function sendForm($form_id)
 {
     $form_model = new wformsFormModel();
     $field_model = new wformsFieldModel();
     $field_values_model = new wformsFieldValuesModel();
     $form = $form_model->getById($form_id);
     if (!$form) {
         throw new waException('Форма #' . $form_id . ' не найдена');
     }
     $fields = $field_model->getFormFields($form_id);
     foreach ($fields as $field) {
         if ($field['type'] != 'file') {
             $value = waRequest::post('field_' . $field['id']);
             if ($field['required'] && empty($value)) {
                 throw new waException('Ошибка отправки формы. Заполните обязательные поля');
             }
             if (is_array($value)) {
                 $data[$field['name']] = implode(', ', $value);
             } else {
                 $data[$field['name']] = $value;
             }
         }
     }
     if (!wa()->getCaptcha()->isValid()) {
         throw new waException('Капча введена неверно');
     }
     $view = wa()->getView();
     $view->assign('data', $data);
     $template_path = wa()->getAppPath('templates/actions/frontend/Message.html', 'wforms');
     $html = $view->fetch($template_path);
     $message = new waMailMessage($form['title'], $html);
     $message->setTo($form['to']);
     foreach ($fields as $field) {
         if ($field['type'] == 'file') {
             $file = waRequest::file('field_' . $field['id']);
             if ($file->uploaded()) {
                 $message->addAttachment($file->tmp_name, $field['name'] . '.' . $file->extension);
             }
         }
     }
     if ($form['from']) {
         $message->setFrom($form['from']);
     }
     if ($message->send()) {
         return true;
     }
     return false;
 }
开发者ID:klxqz,项目名称:wforms,代码行数:48,代码来源:wformsViewHelper.class.php

示例10: execute

 public function execute()
 {
     $data = waRequest::post();
     if (!wa()->getUser()->getRights('photos', 'upload')) {
         throw new waAPIException('access_denied', 403);
     }
     $group_ids = array(0);
     if (!isset($data['status'])) {
         $data['status'] = 1;
     } else {
         if ($data['status'] == -1) {
             $group_ids = array(-wa()->getUser()->getId());
         }
     }
     $data['groups'] = $group_ids;
     $data['source'] = photosPhotoModel::SOURCE_API;
     // work with album
     if (isset($data['album_id'])) {
         $album_id = $data['album_id'];
         $album_model = new photosAlbumModel();
         $album = $album_model->getById($album_id);
         if (!$album) {
             throw new waAPIException('invalid_param', 'Album not found', 404);
         }
         $album_rights_model = new photosAlbumRightsModel();
         if (!$album_rights_model->checkRights($album_id, true)) {
             throw new waAPIException('access_denied', 'Not rights to album', 403);
         }
     }
     $file = waRequest::file('file');
     if (!$file->uploaded()) {
         throw new waAPIException('server_error', $file->error, 500);
     }
     $id = null;
     $photo_model = new photosPhotoModel();
     try {
         $id = $photo_model->add($file, $data);
     } catch (Exception $e) {
         throw new waAPIException('server_error', $e->getMessage(), 500);
     }
     if (!$id) {
         throw new waAPIException('server_error', 500);
     }
     $_GET['id'] = $id;
     $method = new photosPhotoGetInfoMethod();
     $this->response = $method->getResponse(true);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:47,代码来源:photos.photo.add.method.php

示例11: getFilesFromPost

 public static function getFilesFromPost()
 {
     if (waRequest::server('HTTP_X_FILE_NAME')) {
         $name = waRequest::server('HTTP_X_FILE_NAME');
         $size = waRequest::server('HTTP_X_FILE_SIZE');
         $safe_name = trim(preg_replace('~[^a-z\\.]~', '', waLocale::transliterate($name)), ". \n\t\r");
         $safe_name || ($safe_name = uniqid('p'));
         $file_path = wa()->getTempPath('photos/upload/') . $safe_name;
         $append_file = is_file($file_path) && $size > filesize($file_path);
         clearstatcache();
         file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
         $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0));
         return array($file);
     } else {
         return waRequest::file('files');
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:17,代码来源:photosUploadPhoto.controller.php

示例12: execute

 public function execute()
 {
     $this->response['files'] = array();
     $this->model = new photosPhotoModel();
     $data = array('contact_id' => wa()->getUser()->getId(), 'status' => 1, 'groups' => array(0), 'source' => 'publicgallery');
     $plugin = wa()->getPlugin('publicgallery');
     if ($plugin->getSettings('need_moderation')) {
         $data['moderation'] = 0;
     } else {
         $data['moderation'] = 1;
     }
     if ($data['moderation'] <= 0) {
         $data['status'] = 0;
     }
     $this->getStorage()->close();
     if (waRequest::server('HTTP_X_FILE_NAME')) {
         $name = waRequest::server('HTTP_X_FILE_NAME');
         $size = waRequest::server('HTTP_X_FILE_SIZE');
         $file_path = wa()->getTempPath('photos/upload/') . $name;
         $append_file = is_file($file_path) && $size > filesize($file_path);
         clearstatcache();
         file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
         $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0));
         try {
             $this->response['files'][] = $this->save($file, $data);
         } catch (Exception $e) {
             $this->response['files'][] = array('error' => $e->getMessage());
         }
     } else {
         $files = waRequest::file('files');
         foreach ($files as $file) {
             if ($file->error_code != UPLOAD_ERR_OK) {
                 $this->response['files'][] = array('error' => $file->error);
             } else {
                 try {
                     $this->response['files'][] = $this->save($file, $data);
                 } catch (Exception $e) {
                     $this->response['files'][] = array('name' => $file->name, 'error' => $e->getMessage());
                 }
             }
         }
     }
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:43,代码来源:photosPublicgalleryPluginFrontendImageUpload.controller.php

示例13: execute

 public function execute()
 {
     $id = $this->getId();
     $file = waRequest::file('photo');
     if (!$file->uploaded()) {
         $this->sendResponse('error:No file uploaded.');
         return;
     }
     try {
         $img = $file->waImage();
     } catch (Exception $e) {
         // Nope... it's not an image.
         $this->sendResponse('error:File is not an image (' . $e->getMessage() . ').');
         return;
     }
     // save it to a temporary directory (well... less temporary than /tmp)
     // in .jpg format
     $temp_dir = wa()->getTempPath('photo');
     $fname = uniqid($id . '_') . '.jpg';
     $img->save($temp_dir . '/' . $fname, 90);
     $photoEditors = $this->getStorage()->read('photoEditors');
     if (!$photoEditors) {
         $photoEditors = array();
     }
     if (isset($photoEditors[$id]) && file_exists($photoEditors[$id])) {
         // If there was another photo editor session for this contact,
         // assume it closed and delete old temp file
         if (!unlink($photoEditors[$id])) {
             throw new waException('Unable to delete photo temp file: ' + $photoEditors[$id]);
         }
     }
     $photoEditors[$id] = $temp_dir . '/' . $fname;
     // Save file name in session (race condition possible)
     $this->getStorage()->write('photoEditors', $photoEditors);
     // Return temporary file url to browser
     $temp_file_url = $this->getPreviewUrl($fname);
     $this->sendResponse($temp_file_url);
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:38,代码来源:contactsPhotoTmpimage.controller.php

示例14: saveTouchicon

 protected function saveTouchicon()
 {
     $touchicon = waRequest::file('touchicon');
     if ($touchicon->uploaded()) {
         if ($touchicon->extension !== 'png') {
             $this->errors = _w('Files with extension *.png are allowed only.');
         } else {
             $path = wa()->getDataPath('data/' . siteHelper::getDomain() . '/', true);
             if (!file_exists($path) || !is_writable($path)) {
                 $this->errors = sprintf(_w('File could not be saved due to the insufficient file write permissions for the "%s" folder.'), 'wa-data/public/site/data/' . siteHelper::getDomain());
             } elseif (!$touchicon->moveTo($path, 'apple-touch-icon.png')) {
                 $this->errors = _w('Failed to upload file.');
             }
         }
     } elseif ($touchicon->error_code != UPLOAD_ERR_NO_FILE) {
         $this->errors = $touchicon->error;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:18,代码来源:siteSettingsSave.controller.php

示例15: widgetSaveAction

 public function widgetSaveAction()
 {
     $id = waRequest::get('id');
     if (!$id) {
         throw new waException(_ws("Can't save plugin settings: unknown plugin id"));
     }
     $namespace = 'widget_' . $id;
     /**
      * @var shopPlugin $plugin
      */
     $widget = waSystem::getInstance()->getWidget($id);
     $settings = waRequest::post($namespace, array());
     $files = waRequest::file($namespace);
     $settings_defenitions = $widget->getSettings();
     foreach ($files as $name => $file) {
         if (isset($settings_defenitions[$name])) {
             $settings[$name] = $file;
         }
     }
     $response = $widget->setSettings($settings);
     $response['message'] = _w('Saved');
     $this->displayJson($response);
 }
开发者ID:niva79,项目名称:webasyst-framework,代码行数:23,代码来源:webasystDashboard.actions.php


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