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


PHP upload::save方法代码示例

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


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

示例1: save

 /**
  * Uploads a file if we have a valid upload
  *
  * @param   Jelly  $model
  * @param   mixed  $value
  * @param   bool   $loaded
  * @return  string|NULL
  */
 public function save($model, $value, $loaded)
 {
     $original = $model->get($this->name, FALSE);
     // Upload a file?
     if (is_array($value) and upload::valid($value)) {
         if (FALSE !== ($filename = upload::save($value, NULL, $this->path))) {
             // Chop off the original path
             $value = str_replace($this->path, '', $filename);
             // Ensure we have no leading slash
             if (is_string($value)) {
                 $value = trim($value, '/');
             }
             // Delete the old file if we need to
             if ($this->delete_old_file and $original != $this->default) {
                 $path = $this->path . $original;
                 if (file_exists($path)) {
                     unlink($path);
                 }
             }
         } else {
             $value = $this->default;
         }
     }
     return $value;
 }
开发者ID:rcapp,项目名称:kohana-jelly,代码行数:33,代码来源:file.php

示例2: __call

 public function __call($function, $args)
 {
     $input = Input::instance();
     $request = new stdClass();
     switch ($method = strtolower($input->server("REQUEST_METHOD"))) {
         case "get":
             $request->params = (object) $input->get();
             break;
         case "post":
             $request->params = (object) $input->post();
             if (isset($_FILES["file"])) {
                 $request->file = upload::save("file");
             }
             break;
     }
     $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method));
     $request->access_token = $input->server("HTTP_X_GALLERY_REQUEST_KEY");
     $request->url = url::abs_current(true);
     rest::set_active_user($request->access_token);
     $handler_class = "{$function}_rest";
     $handler_method = $request->method;
     if (!method_exists($handler_class, $handler_method)) {
         throw new Rest_Exception("Bad Request", 400);
     }
     try {
         rest::reply(call_user_func(array($handler_class, $handler_method), $request));
     } catch (ORM_Validation_Exception $e) {
         foreach ($e->validation->errors() as $key => $value) {
             $msgs[] = "{$key}: {$value}";
         }
         throw new Rest_Exception("Bad Request: " . join(", ", $msgs), 400);
     }
 }
开发者ID:andyst,项目名称:gallery3,代码行数:33,代码来源:rest.php

示例3: add_photo

 public function add_photo($id)
 {
     $album = ORM::factory("item", $id);
     access::required("view", $album);
     access::required("add", $album);
     access::verify_csrf();
     $file_validation = new Validation($_FILES);
     $file_validation->add_rules("Filedata", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]");
     if ($file_validation->validate()) {
         // SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
         if (!batch::in_progress()) {
             batch::start();
         }
         $temp_filename = upload::save("Filedata");
         try {
             $name = substr(basename($temp_filename), 10);
             // Skip unique identifier Kohana adds
             $title = item::convert_filename_to_title($name);
             $path_info = pathinfo($temp_filename);
             if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
                 $movie = movie::create($album, $temp_filename, $name, $title);
                 log::success("content", t("Added a movie"), html::anchor("movies/{$movie->id}", t("view movie")));
             } else {
                 $photo = photo::create($album, $temp_filename, $name, $title);
                 log::success("content", t("Added a photo"), html::anchor("photos/{$photo->id}", t("view photo")));
             }
         } catch (Exception $e) {
             unlink($temp_filename);
             throw $e;
         }
         unlink($temp_filename);
     }
     print "File Received";
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:34,代码来源:simple_uploader.php

示例4: upload_csv

 /** 
  * Upload function for a JNCC style designations spreadsheet.
  */
 public function upload_csv()
 {
     try {
         // We will be using a POST array to send data, and presumably a FILES array for the
         // media.
         // Upload size
         $ups = Kohana::config('indicia.maxUploadSize');
         $_FILES = Validation::factory($_FILES)->add_rules('csv_upload', 'upload::valid', 'upload::required', 'upload::type[csv]', "upload::size[{$ups}]");
         if (count($_FILES) === 0) {
             echo "No file was uploaded.";
         } elseif ($_FILES->validate()) {
             if (array_key_exists('name_is_guid', $_POST) && $_POST['name_is_guid'] == 'true') {
                 $finalName = strtolower($_FILES['csv_upload']['name']);
             } else {
                 $finalName = time() . strtolower($_FILES['csv_upload']['name']);
             }
             $fTmp = upload::save('csv_upload', $finalName);
             url::redirect('taxon_designation/import_progress?file=' . urlencode(basename($fTmp)));
         } else {
             kohana::log('error', 'Validation errors uploading file ' . $_FILES['csv_upload']['name']);
             kohana::log('error', print_r($_FILES->errors('form_error_messages'), true));
             throw new ValidationError('Validation error', 2004, $_FILES->errors('form_error_messages'));
         }
     } catch (Exception $e) {
         $this->handle_error($e);
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:30,代码来源:taxon_designation.php

示例5: action_archivos

 public function action_archivos()
 {
     $errors = array();
     $id = $_GET['contra'];
     $proceso = ORM::factory('gestiones', $id);
     if ($_POST) {
         $id_archivo = 0;
         $archivo_texto = '';
         $post = Validation::factory($_FILES)->rule('archivo', 'Upload::not_empty')->rule('archivo', 'Upload::type', array(':value', array('jpg', 'png', 'gif', 'pdf', 'doc', 'docx', 'ppt', 'xls', 'xlsx')))->rule('archivo', 'Upload::size', array(':value', '3M'));
         // ->rules ( 'archivo', array (array ('Upload::valid' ), array ('Upload::type', array (':value', array ('pdf', 'doc', 'docx', 'ppt', 'xls', 'xlsx' ) ) ), array ('Upload::size', array (':value', '5M' ) ) ) );
         //si pasa la validacion guardamamos
         if ($post->check()) {
             //guardamos el archivo
             $filename = upload::save($_FILES['archivo1']);
             $archivo1 = ORM::factory('archivos1');
             //intanciamos el modelo
             $archivo1->archivo = basename($filename);
             $archivo1->extension = $_FILES['archivo']['type'];
             $archivo1->size = $_FILES['archivo']['size'];
             $archivo1->fecha = date('Y-m-d');
             $archivo1->proceso_id = $_POST['proceso_id'];
             // $archivo->id = $nuevo->id;
             $archivo->save();
             $_POST = array();
             //enviamos email
             // $this->template->content=View::factory('digitales');
         } else {
             $errors['Datos'] = 'No se pudo guardar, vuelva a intentarlo';
         }
     } else {
         $errors['Archivos'] = 'Ocurrio un error al subir el archivo';
     }
     $archivos = ORM::factory('archivos')->where('proceso_id', '=', $id)->find_all();
     $this->template->content = View::factory('Archivos')->bind('errors', $errors)->bind('proceso', $proceso)->bind('archivos', $archivos);
 }
开发者ID:sysdevbol,项目名称:entidad,代码行数:35,代码来源:archivos1.php

示例6: action_index

 public function action_index()
 {
     if ($_POST) {
         try {
             foreach ($_POST['option'] as $option_id => $value) {
                 $option = ORM::factory('Option', $option_id);
                 $option->value = $value;
                 $option->save();
             }
             if (arr::get($_FILES, 'option', false)) {
                 foreach ($_FILES['option']['name'] as $key => $file) {
                     $ext = $_FILES['option']['name'][$key];
                     $ext = explode('.', $ext);
                     $ext = end($ext);
                     $filename = upload::save(array('name' => $_FILES['option']['name'][$key], 'type' => $_FILES['option']['type'][$key], 'tmp_name' => $_FILES['option']['tmp_name'][$key], 'error' => $_FILES['option']['error'][$key], 'size' => $_FILES['option']['size'][$key]), 'option-' . $key . '.' . $ext, 'media/uploads');
                     $option = ORM::factory('Option', $key);
                     $option->value = 'option-' . $key . '.' . $ext;
                     $option->save();
                 }
             }
             ajax::success(__('Settings saved'));
         } catch (ORM_Validation_Exception $e) {
             ajax::error(__('An error occured and the settings couldn\'t be saved: :error', array(':error' => $e->getMessage())));
         }
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:26,代码来源:Options.php

示例7: postSave

 public function postSave()
 {
     $modified = $this->getModified(FALSE, TRUE);
     if ((array_key_exists('description', $modified) or array_key_exists('name', $modified)) and !$this->skip_desc_propagate) {
         $resampled = $this->get_resampled();
         foreach ($resampled as $key => $mediafile) {
             $differs = FALSE;
             if ($this->get('mediafile_id') == $mediafile['mediafile_id']) {
                 continue;
             }
             if ($this->get('description') != $mediafile['description']) {
                 $differs = TRUE;
                 $resampled[$key]['description'] = $this->get('description');
             }
             if ($this->get('name') != $mediafile['name']) {
                 $differs = TRUE;
                 $resampled[$key]['name'] = $this->get('name');
             }
             if (!$differs) {
                 continue;
             }
             kohana::log('debug', 'Copy media file description or name from ' . $this->get('mediafile_id') . ' to ' . $mediafile['mediafile_id']);
             $mediafile->skip_desc_propagate = TRUE;
             $resampled[$key]->save();
             $mediafile->skip_desc_propagate = FALSE;
         }
     }
     if (!$this->uploaded_file) {
         return;
     }
     kohana::log('debug', 'Moving upload "' . $this->uploaded_file['tmp_name'] . '" to "' . $this->filepath(TRUE) . '"');
     if (!upload::save($this->uploaded_file, $this->get('file'), $this->filepath())) {
         throw new Exception('Unable to save file to system');
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:35,代码来源:MediaFile.php

示例8: save

 function save($id = null, $data)
 {
     global $osC_Database, $osC_Language, $osC_Image;
     if (is_numeric($id)) {
         foreach ($osC_Language->getAll() as $l) {
             $image_upload = new upload('image' . $l['id'], DIR_FS_CATALOG . 'images/');
             if ($image_upload->exists() && $image_upload->parse() && $image_upload->save()) {
                 $Qdelete = $osC_Database->query('select image from :table_slide_images where image_id = :image_id and language_id=:language_id');
                 $Qdelete->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
                 $Qdelete->bindInt(':image_id', $id);
                 $Qdelete->bindValue(':language_id', $l['id']);
                 $Qdelete->execute();
                 if ($Qdelete->numberOfRows() > 0) {
                     @unlink(DIR_FS_CATALOG . 'images/' . $Qdelete->value('image'));
                 }
                 $Qimage = $osC_Database->query('update :table_slide_images set image = :image, description = :description, image_url = :image_url, sort_order = :sort_order, status = :status where image_id = :image_id and language_id=:language_id');
                 $Qimage->bindValue(':image', $image_upload->filename);
             } else {
                 $Qimage = $osC_Database->query('update :table_slide_images set description = :description, image_url = :image_url, sort_order = :sort_order, status = :status where image_id = :image_id and language_id=:language_id');
             }
             $Qimage->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
             $Qimage->bindValue(':description', $data['description'][$l['id']]);
             $Qimage->bindValue(':image_url', $data['image_url'][$l['id']]);
             $Qimage->bindValue(':sort_order', $data['sort_order']);
             $Qimage->bindValue(':status', $data['status']);
             $Qimage->bindInt(':image_id', $id);
             $Qimage->bindValue(':language_id', $l['id']);
             $Qimage->execute();
         }
     } else {
         $Qmaximage = $osC_Database->query('select max(image_id) as image_id from :table_slide_images');
         $Qmaximage->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
         $Qmaximage->execute();
         $image_id = $Qmaximage->valueInt('image_id') + 1;
         foreach ($osC_Language->getAll() as $l) {
             $products_image = new upload('image' . $l['id'], DIR_FS_CATALOG . 'images/');
             if ($products_image->exists() && $products_image->parse() && $products_image->save()) {
                 $Qimage = $osC_Database->query('insert into :table_slide_images (image_id,language_id ,description,image ,image_url ,sort_order,status) values (:image_id,:language_id,:description ,:image,:image_url ,:sort_order,:status)');
                 $Qimage->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES);
                 $Qimage->bindValue(':image_id', $image_id);
                 $Qimage->bindValue(':language_id', $l['id']);
                 $Qimage->bindValue(':description', $data['description'][$l['id']]);
                 $Qimage->bindValue(':image', $products_image->filename);
                 $Qimage->bindValue(':image_url', $data['image_url'][$l['id']]);
                 $Qimage->bindValue(':sort_order', $data['sort_order']);
                 $Qimage->bindValue(':status', $data['status']);
                 $Qimage->execute();
             }
         }
     }
     if ($osC_Database->isError()) {
         return false;
     } else {
         osC_Cache::clear('slide-images');
         return true;
     }
 }
开发者ID:sajad1441,项目名称:TomatoShop-v1,代码行数:57,代码来源:slide_images.php

示例9: add_photo

 public function add_photo($id)
 {
     $album = ORM::factory("item", $id);
     access::required("view", $album);
     access::required("add", $album);
     access::verify_csrf();
     // The Flash uploader not call /start directly, so simulate it here for now.
     if (!batch::in_progress()) {
         batch::start();
     }
     $form = $this->_get_add_form($album);
     // Uploadify adds its own field to the form, so validate that separately.
     $file_validation = new Validation($_FILES);
     $file_validation->add_rules("Filedata", "upload::valid", "upload::required", "upload::type[" . implode(",", legal_file::get_extensions()) . "]");
     if ($form->validate() && $file_validation->validate()) {
         $temp_filename = upload::save("Filedata");
         Event::add("system.shutdown", create_function("", "unlink(\"{$temp_filename}\");"));
         try {
             $item = ORM::factory("item");
             $item->name = substr(basename($temp_filename), 10);
             // Skip unique identifier Kohana adds
             $item->title = item::convert_filename_to_title($item->name);
             $item->parent_id = $album->id;
             $item->set_data_file($temp_filename);
             // Remove double extensions from the filename - they'll be disallowed in the model but if
             // we don't do it here then it'll result in a failed upload.
             $item->name = legal_file::smash_extensions($item->name);
             $path_info = @pathinfo($temp_filename);
             if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), legal_file::get_movie_extensions())) {
                 $item->type = "movie";
                 $item->save();
                 log::success("content", t("Added a movie"), html::anchor("movies/{$item->id}", t("view movie")));
             } else {
                 $item->type = "photo";
                 $item->save();
                 log::success("content", t("Added a photo"), html::anchor("photos/{$item->id}", t("view photo")));
             }
             module::event("add_photos_form_completed", $item, $form);
         } catch (Exception $e) {
             // The Flash uploader has no good way of reporting complex errors, so just keep it simple.
             Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
             // Ugh.  I hate to use instanceof, But this beats catching the exception separately since
             // we mostly want to treat it the same way as all other exceptions
             if ($e instanceof ORM_Validation_Exception) {
                 Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1));
             }
             header("HTTP/1.1 500 Internal Server Error");
             print "ERROR: " . $e->getMessage();
             return;
         }
         print "FILEID: {$item->id}";
     } else {
         header("HTTP/1.1 400 Bad Request");
         print "ERROR: " . t("Invalid upload");
     }
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:56,代码来源:uploader.php

示例10: action_save

 public function action_save($pid = null)
 {
     $data = (object) filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
     $photo = ORM::factory("dlsliderphoto", $pid);
     $slider = ORM::factory("dlslidergroup", $data->slider_id);
     $new = empty($photo->id);
     if (!$slider->loaded()) {
         Message::set(Message::ERROR, "Something unexpected happened. Please try again.");
         $this->request->redirect("admin/dlslider/");
         return;
     }
     $files = Validate::factory($_FILES);
     $files->rule('photo', 'Upload::type', array(array('jpg', 'png', 'gif')));
     foreach ($data as $val) {
         if (empty($val)) {
             Message::set(Message::ERROR, "All fields must be filled in.");
             $this->request->redirect("admin/dlslider/edit/{$slider->id}");
             return;
         }
     }
     $photo->title = $data->title;
     $photo->teaser = $data->teaser;
     $photo->link_text = $data->linktext;
     $photo->link = $data->link;
     $photo->saved = isset($data->save) ? 1 : 0;
     if (empty($photo->position)) {
         $photo->position = $slider->allPhotos->count() + 1;
     }
     if ($files->check()) {
         if ($_FILES['photo']['error'] == 0) {
             $filename = upload::save($_FILES['photo'], $_FILES['photo']['name'], Kohana::config('myshot.relativeBase'));
             // New file name
             $new_filename = rand(0, 1000) . "_" . substr($_FILES['photo']['name'], 0, strlen($_FILES['photo']['name']) - 4) . '-resized' . substr($_FILES['photo']['name'], -4);
             $localFile = Kohana::config('myshot.relativeBase') . $new_filename;
             // Resize, sharpen, and save the image
             Image::factory($filename)->resize(Model_DLSliderPhoto::WIDTH, Model_DLSliderPhoto::HEIGHT, Image::WIDTH)->crop(Model_DLSliderPhoto::WIDTH, Model_DLSliderPhoto::HEIGHT, 0, 0)->save($localFile);
             Library_Akamai::factory()->addToDir($localFile, "dlslider", date("Y-m"));
             $photo->filename = "dlslider/" . date("Y-m") . "/{$new_filename}";
             // Remove the temporary files
             unlink($filename);
             unlink($localFile);
         }
     }
     if (empty($photo->filename)) {
         Message::set(Message::ERROR, "Something was wrong with the file to upload. Please check the file try again.");
         $this->request->redirect("admin/dlslider/edit/{$slider->id}");
         return;
     }
     $photo->save();
     if ($new) {
         DB::update("dl_slider_group_dl_slider_photos")->set(array("position" => $slider->allPhotos->count()))->where("dl_slider_group_id", "=", $slider->id)->where("dl_slider_photos_id", "=", $photo->id)->execute();
     }
     !$slider->has("photos", $photo) ? $slider->add("photos", $photo) : null;
     Message::set(Message::SUCCESS, "Image Added");
     $this->request->redirect("admin/dlslider/edit/{$slider->id}");
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:56,代码来源:dlslider.php

示例11: storeFileUpload

 function storeFileUpload($file, $directory)
 {
     if (is_writeable($directory)) {
         $upload = new upload($file, $directory);
         if ($upload->exists() && $upload->parse() && $upload->save()) {
             return true;
         }
     }
     return false;
 }
开发者ID:4DvAnCeBoY,项目名称:tomatocart-shoppingcart,代码行数:10,代码来源:file_manager.php

示例12: execute

 function execute()
 {
     global $osC_Session, $osC_Product, $toC_Customization_Fields, $osC_Language, $messageStack;
     if (!isset($osC_Product)) {
         $id = false;
         foreach ($_GET as $key => $value) {
             if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) {
                 $id = $key;
             }
             break;
         }
         if ($id !== false && osC_Product::checkEntry($id)) {
             $osC_Product = new osC_Product($id);
         }
     }
     if (isset($osC_Product)) {
         $errors = array();
         $data = array();
         $customizations = $osC_Product->getCustomizations();
         foreach ($customizations as $field) {
             $fields_id = $field['customization_fields_id'];
             if ($field['type'] == CUSTOMIZATION_FIELD_TYPE_INPUT_TEXT) {
                 $value = isset($_POST['customizations'][$fields_id]) ? $_POST['customizations'][$fields_id] : null;
                 if ($field['is_required'] && $value == null) {
                     $messageStack->add_session('products_customizations', sprintf($osC_Language->get('error_customization_field_must_be_specified'), $field['name']), 'error');
                 } else {
                     if ($value != null) {
                         $data[$fields_id] = array('customization_fields_id' => $field['customization_fields_id'], 'customization_fields_name' => $field['name'], 'customization_type' => CUSTOMIZATION_FIELD_TYPE_INPUT_TEXT, 'customization_value' => $value);
                     }
                 }
             } else {
                 $file = new upload('customizations_' . $fields_id, DIR_FS_CACHE . '/products_customizations/');
                 if ($field['is_required'] && !$file->exists() && !$toC_Customization_Fields->hasCustomizationField($osC_Product->getID(), $fields_id)) {
                     $messageStack->add_session('products', sprintf($osC_Language->get('error_customization_field_must_be_specified'), $field['name']), 'error');
                 } else {
                     if ($file->exists()) {
                         if ($file->parse() && $file->save()) {
                             $filename = $file->filename;
                             $cache_filename = md5($filename . time());
                             rename(DIR_FS_CACHE . '/products_customizations/' . $filename, DIR_FS_CACHE . '/products_customizations/' . $cache_filename);
                             $data[$fields_id] = array('customization_fields_id' => $field['customization_fields_id'], 'customization_fields_name' => $field['name'], 'customization_type' => CUSTOMIZATION_FIELD_TYPE_INPUT_FILE, 'customization_value' => $filename, 'cache_filename' => $cache_filename);
                         } else {
                             $messageStack->add_session('products_customizations', $file->getLastError(), 'error');
                         }
                     }
                 }
             }
         }
         //var_dump($data);exit;
         if ($messageStack->size('products_customizations') === 0) {
             $toC_Customization_Fields->set($osC_Product->getID(), $data);
         }
     }
     osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()));
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:55,代码来源:save_customization_fields.php

示例13: __call

 public function __call($function, $args)
 {
     try {
         $input = Input::instance();
         $request = new stdClass();
         switch ($method = strtolower($input->server("REQUEST_METHOD"))) {
             case "get":
                 $request->params = (object) $input->get();
                 break;
             default:
                 $request->params = (object) $input->post();
                 if (isset($_FILES["file"])) {
                     $request->file = upload::save("file");
                     system::delete_later($request->file);
                 }
                 break;
         }
         if (isset($request->params->entity)) {
             $request->params->entity = json_decode($request->params->entity);
         }
         if (isset($request->params->members)) {
             $request->params->members = json_decode($request->params->members);
         }
         $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method));
         $request->access_key = $input->server("HTTP_X_GALLERY_REQUEST_KEY");
         if (empty($request->access_key) && !empty($request->params->access_key)) {
             $request->access_key = $request->params->access_key;
         }
         $request->url = url::abs_current(true);
         if ($suffix = Kohana::config('core.url_suffix')) {
             $request->url = substr($request->url, 0, strlen($request->url) - strlen($suffix));
         }
         rest::set_active_user($request->access_key);
         $handler_class = "{$function}_rest";
         $handler_method = $request->method;
         if (!class_exists($handler_class) || !method_exists($handler_class, $handler_method)) {
             throw new Rest_Exception("Bad Request", 400);
         }
         $response = call_user_func(array($handler_class, $handler_method), $request);
         if ($handler_method == "post") {
             // post methods must return a response containing a URI.
             header("HTTP/1.1 201 Created");
             header("Location: {$response['url']}");
         }
         rest::reply($response);
     } catch (ORM_Validation_Exception $e) {
         // Note: this is totally insufficient because it doesn't take into account localization.  We
         // either need to map the result values to localized strings in the application code, or every
         // client needs its own l10n string set.
         throw new Rest_Exception("Bad Request", 400, $e->validation->errors());
     } catch (Kohana_404_Exception $e) {
         throw new Rest_Exception("Not Found", 404);
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:54,代码来源:rest.php

示例14: action_lista

 public function action_lista()
 {
     $errors = array();
     $id = $_GET['contra'];
     $tipo = $_GET['tipo'];
     switch ($tipo) {
         case 3:
             $proceso = ORM::factory('gestiones', $id);
             $nombre = $proceso->numContratacion;
             break;
         case 2:
             $proceso = ORM::factory('viviendas', $id);
             $nombre = $proceso->serDocumental;
             break;
         default:
             $proceso = ORM::factory('centrales', $id);
             $nombre = 'Serie Documental: ' . $proceso->serDocumental;
             break;
     }
     if ($_POST) {
         $id_archivo = 0;
         $archivo_texto = '';
         $post = Validation::factory($_FILES)->rule('archivo', 'Upload::not_empty')->rule('archivo', 'Upload::type', array(':value', array('pdf', 'doc', 'docx', 'xlsx')))->rule('archivo', 'Upload::size', array(':value', '3M'));
         // ->rules ( 'archivo', array (array ('Upload::valid' ), array ('Upload::type', array (':value', array ('pdf', 'doc', 'docx', 'ppt', 'xls', 'xlsx' ) ) ), array ('Upload::size', array (':value', '5M' ) ) ) );
         //si pasa la validacion guardamamos
         if ($post->check()) {
             //guardamos el archivo
             $filename = upload::save($_FILES['archivo']);
             $archivo = ORM::factory('aarchivos');
             //intanciamos el modelo
             $archivo->archivo = basename($filename);
             $archivo->extension = $_FILES['archivo']['type'];
             $archivo->size = $_FILES['archivo']['size'];
             $archivo->fecha = date('Y-m-d H:i:s');
             $archivo->proceso_id = $_POST['proceso_id'];
             $archivo->central_id = $tipo;
             $archivo->user_id = $this->template->user->id;
             // $archivo->id = $nuevo->id;
             $archivo->save();
             $_POST = array();
             //enviamos email
             // $this->template->content=View::factory('digitales');
         } else {
             $errors['Datos'] = 'No se pudo guardar, vuelva a intentarlo';
         }
     } else {
         $errors['Archivos'] = 'Ocurrio un error al subir el archivo';
     }
     //obentemos los archivos dato el tipo y el proceso
     $archivos = ORM::factory('aarchivos')->where('proceso_id', '=', $id)->where('central_id', '=', $tipo)->find_all();
     $this->template->content = View::factory('archivero/lista_archivos')->bind('errors', $errors)->bind('proceso', $proceso)->bind('nombre', $nombre)->bind('archivos', $archivos);
 }
开发者ID:sysdevbol,项目名称:entidad,代码行数:52,代码来源:archivo.php

示例15: array

 function get_upload_file($fld)
 {
     global $UploadCache;
     if (!isset($UploadCache)) {
         $UploadCache = array();
     }
     if (!isset($UploadCache[$fld])) {
         $model_image_obj = new upload($fld);
         $model_image_obj->set_destination(DIR_FS_CATALOG_IMAGES);
         $UploadCache[$fld] = $model_image_obj->parse() && $model_image_obj->save() ? $model_image_obj->filename : '';
     }
     //echo 'get_upload_file('.$fld.")=".$UploadCache[$fld]."\n";
     return $UploadCache[$fld];
 }
开发者ID:rrecurse,项目名称:IntenseCart,代码行数:14,代码来源:gift_certs.php


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