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


PHP Photo::save方法代码示例

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


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

示例1: savePhoto

 /**
  *新的的话就要新建一个guide,旧的的话就是要将photo直接保存即可
  */
 public function savePhoto(Photo &$photo)
 {
     if ($this->isNewRecord) {
         $this->title = Scenic::model()->findByPk($photo->scenicId);
         $this->userId = Yii::app()->user->userId;
         $this->save();
         $photo->guideId = $this->guideId;
         $photo->save();
     } else {
         if ($photo->save()) {
             $this->save();
         }
     }
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:17,代码来源:Guide.php

示例2: saveCreate

 public function saveCreate()
 {
     $input = Input::all();
     $task = new Photo();
     $task->title = $input['title'];
     $task->description = $input['description'];
     $task->category = $input['category'];
     // $task->path = base_path() . '/public/uploads/' . $input['image']->getClientOriginalName();
     // getting the name of the image
     $filename = time() . $input['image']->getClientOriginalName();
     //attaching the image name with the src path and save to path
     $task->path = 'uploads/' . $filename;
     //before the image is moved to the uploads folder we resize with intervention
     $background = Image::canvas(650, 650);
     $image = Input::file('image');
     $newimage = Image::make($image)->resize(650, 650, function ($c) {
         $c->aspectRatio();
         $c->upsize();
     });
     $background->insert($newimage, 'center');
     //moving the image to the uploads folder
     $savepath = 'public/uploads';
     $background->save(base_path() . '/public/uploads/' . $filename);
     $task->save();
     return Redirect::action('HomeController@home');
 }
开发者ID:Owohlet,项目名称:VittonGlobalLimited,代码行数:26,代码来源:HomeController.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Photo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Photo'])) {
         $model->attributes = $_POST['Photo'];
         if (isset($_FILES['images']['name'][0]) && $_FILES['images']['name'][0] !== '') {
             $model->name = 'new';
         }
         if ($model->validate()) {
             $images = CUploadedFile::getInstancesByName('images');
             foreach ($images as $image) {
                 $imageModel = new Photo();
                 $name = uniqid() . $image->name;
                 $image->saveAs(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name);
                 copy(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name, Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb = Yii::app()->image->load(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb->resize(300, 300);
                 $thumb->save();
                 $imageModel->name = $name;
                 $imageModel->category_id = $_POST['Photo']['category_id'];
                 $imageModel->save();
             }
             Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
             $this->refresh();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка!'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:Vladimirtishenko,项目名称:val.ua,代码行数:36,代码来源:PhotoController.php

示例4: __construct

 public function __construct()
 {
     gateKeeper();
     $user = getLoggedInUser();
     $user->createAvatar();
     if (isEnabledPlugin("photos")) {
         $album = getEntity(array("type" => "Photoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "Profile Avatars"))));
         $photo = new Photo();
         $photo->owner_guid = getLoggedInUserGuid();
         $photo_guid = $photo->save();
         Image::copyAvatar($user, $photo);
         $photo = getEntity($photo_guid);
         if (!$album) {
             $album = new Photoalbum();
             $album->owner_guid = getLoggedInUserGuid();
             $album->title = "Profile Avatars";
             $album_guid = $album->save();
             $album = getEntity($album_guid);
             Image::copyAvatar($photo, $album);
         }
         $photo->container_guid = $album->guid;
         $photo->save();
     }
     runHook("action:edit_avatar:after", array("user" => $user));
     new Activity(getLoggedInUserGuid(), "activity:avatar:updated", array($user->getURL(), $user->full_name));
     new SystemMessage("Your avatar has been uploaded.");
     forward("profile/" . $user->guid);
 }
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:28,代码来源:EditAvatarActionHandler.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $imageName = '';
     $imagePath = public_path() . '/img/';
     if (Input::hasFile('photo')) {
         $img = Input::file('photo');
         $imageName = str_random(6) . '_' . $img->getClientOriginalName();
         $img->move($imagePath, $imageName);
         $img = Image::make($imagePath . $imageName);
         $img->save($imagePath . $imageName);
         $thumb = Image::make($imagePath . $imageName);
         $thumbName = $imageName;
         $thumbPath = public_path() . '/thumbs/img/';
         $thumb->resize(100, 100);
         $thumb->save($thumbPath . $thumbName);
         $imgEntry = new Photo();
         $imgEntry->user_id = Auth::user()->id;
         $imgEntry->caption = Input::get('caption');
         $imgEntry->path = 'img/' . $imageName;
         $imgEntry->save();
         return Response::json(array('error' => false, 'message' => 'Upload successful.'), 200);
     } else {
         return Response::json(array('error' => 'true', 'photos' => null), 200);
     }
 }
开发者ID:jbrown25,项目名称:PhotoSharing-PHP-backend,代码行数:30,代码来源:PhotoController.php

示例6: __construct

 public function __construct()
 {
     $editor = getInput("editor_id");
     if (file_exists($_FILES['avatar']['tmp_name'])) {
         // Check if General album exists
         $album = getEntity(array("type" => "Photoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "General"))));
         $photo = new Photo();
         $photo->owner_guid = getLoggedInUserGuid();
         $photo->save();
         $photo->createAvatar();
         if (!$album) {
             $album = new Photoalbum();
             $album->title = "General";
             $album->owner_guid = getLoggedInUserGuid();
             $album->access_id = "public";
             Image::copyAvatar($photo, $album);
             $album->save();
         }
         $photo->container_guid = $album->guid;
         if (!$album->title != "Profile Avatars" && $album->title != "General") {
             new Activity(getLoggedInUserGuid(), "activity:add:photo", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $album->getURL(), $album->title, "<a href='" . $album->getURL() . "'>" . $photo->icon(EXTRALARGE, "img-responsive") . "</a>"), $album->access_id);
         }
         $photo->save();
         forward(false, array("insertphoto" => $photo->guid, "editor" => $editor));
     } else {
         forward();
     }
 }
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:28,代码来源:UploadPhotoActionHandler.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $id = Auth::user()->ID;
     $files = Input::file('files');
     $assetPath = '/uploads/' . $id;
     $uploadPath = public_path($assetPath);
     $results = array();
     foreach ($files as $file) {
         if ($file->getSize() > $_ENV['max_file_size']) {
             $results[] = array("name" => $file->getClientOriginalName(), "size" => $file->getSize(), "error" => "Please upload file less than " . $_ENV['max_file_size'] / 1000000 . "mb");
         } else {
             //rename filename so that it won't overlap with existing file
             $extension = $file->getClientOriginalExtension();
             $filename = time() . Str::random(20) . "." . $extension;
             // store our uploaded file in our uploads folder
             $name = $assetPath . '/' . $filename;
             $photo_attributes = array('name' => $filename, 'size' => $file->getSize(), 'url' => asset($name), 'user_id' => $id);
             $photo = new Photo($photo_attributes);
             if ($photo->save()) {
                 if (!is_dir($uploadPath)) {
                     mkdir($uploadPath, 0777);
                 }
                 //resize image into different sizes
                 foreach (Photo::getThumbnailSizes() as $key => $thumb) {
                     Image::make($file->getRealPath())->resize($thumb['width'], $thumb['height'])->save($uploadPath . "/" . $key . "-" . $filename);
                 }
                 //save original file
                 $file->move($uploadPath, $filename);
                 $results[] = Photo::find($photo->id)->find_in_json();
             }
         }
     }
     // return our results in a files object
     return json_encode(array('files' => $results));
 }
开发者ID:shankargiri,项目名称:Quantum-Vic-La-Trobe-L4,代码行数:40,代码来源:PhotosController.php

示例8: post_new_city

 public function post_new_city()
 {
     $rules = array('city' => 'required|unique:photos', 'picture' => 'required');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::to('admin/cityphotos')->with_errors($v)->with_input();
     } else {
         $new_photo = array('city' => ucwords(Input::get('city')));
         $photo = new Photo($new_photo);
         if ($photo->save()) {
             $upload_path = path('public') . Photo::$upload_path_city . $photo->city;
             if (!File::exists($upload_path)) {
                 File::mkdir($upload_path);
             }
             $filename = $photo->city . '.jpg';
             $path_to_file = $upload_path . '/' . $filename;
             $dynamic_path = '/' . Photo::$upload_path_city . $photo->city . '/' . $filename;
             $success = Resizer::open(Input::file('picture'))->resize(1024, 724, 'auto')->save($path_to_file, 75);
             if ($success) {
                 $new_photo = Photo::find($photo->id);
                 $new_photo->location = $dynamic_path;
                 $new_photo->save();
             }
             return Redirect::to('admin/cityphotos')->with('msg', '<div class="alert alert-success"><strong>City foto is geupload!</strong></div>');
         } else {
             return Redirect::to('admin/cityphotos')->with('msg', '<div class="alert alert-error"><strong>Er is iets mis gegaan bij het toevoegen.</strong></div>');
         }
     }
 }
开发者ID:sanneterpstra,项目名称:Kamergenood,代码行数:29,代码来源:photo.php

示例9: addPost

 public function addPost()
 {
     // let's setup some rules for our new data
     // I'm sure you can come up with better ones
     $rules = array('title' => 'required|min:3|max:128', 'file' => 'mimes:jpg,gif,png');
     $pictrue = '';
     $title = Input::get('title');
     $description = Input::get('description');
     $author_id = Input::get('author_id');
     $tags = Input::get('tags');
     if (Input::hasFile('file')) {
         $file = Input::file('file');
         $ext = $file->guessClientExtension();
         $filename = $file->getClientOriginalName();
         $file->move(public_path() . '/data', md5(date('YmdHis') . $filename) . '.' . $ext);
         $pictrue = md5(date('YmdHis') . $filename) . '.' . $ext;
     }
     $new_photo = array('title' => $title, 'description' => $description, 'author_id' => $author_id, 'views' => 0, 'pictrue' => $pictrue, 'tags' => $tags);
     $v = Validator::make($new_photo, $rules);
     if ($v->fails()) {
         // redirect back to the form with
         // errors, input and our currently
         // logged in user
         return Redirect::to('photo/add')->with('user', Auth::user())->withErrors($v)->withInput();
     }
     // create the new post
     $photo = new Photo($new_photo);
     $photo->save();
     // redirect to viewing our new post
     return Redirect::to('photo/view/' . $photo->id);
 }
开发者ID:shinichi81,项目名称:laravel4demo,代码行数:31,代码来源:PhotoController.php

示例10: post_new

 public function post_new()
 {
     $rules = array('title' => 'required|min:5|max:128', 'street' => 'required', 'postalcode' => 'required|match:#^[1-9][0-9]{3}\\h*[A-Z]{2}$#i', 'city' => 'required', 'type' => 'required', 'surface' => 'required|integer', 'price' => 'required|numeric|max:1500|min:100', 'date' => 'required|after:' . date('d-m-Y'), 'pictures' => 'required|image|max:3000', 'register' => 'required', 'email' => 'required|email|same:email2', 'description' => 'required|min:30', 'captchatest' => 'laracaptcha|required', 'terms' => 'accepted');
     $v = Validator::make(Input::all(), $rules, Room::$messages);
     if ($v->fails()) {
         return Redirect::to('kamer-verhuren')->with_errors($v)->with('msg', '<div class="alert alert-error"><strong>Verplichte velden zijn niet volledig ingevuld</strong><br />Loop het formulier nogmaals na.</div>')->with_input();
     } else {
         if (Auth::check()) {
             $status = 'publish';
         } else {
             $status = 'pending';
         }
         $new_room = array('title' => ucfirst(Input::get('title')), 'street' => ucwords(Input::get('street')), 'housenr' => Input::get('housenr'), 'postalcode' => Input::get('postalcode'), 'city' => ucwords(Input::get('city')), 'type' => Input::get('type'), 'surface' => Input::get('surface'), 'price' => Input::get('price'), 'available' => date("Y-m-d", strtotime(Input::get('date'))), 'gender' => Input::get('gender'), 'pets' => Input::get('pets'), 'smoking' => Input::get('smoking'), 'toilet' => Input::get('toilet'), 'shower' => Input::get('shower'), 'kitchen' => Input::get('kitchen'), 'register' => Input::get('register'), 'social' => Input::get('social'), 'email' => strtolower(Input::get('email')), 'description' => ucfirst(Input::get('description')), 'status' => $status, 'url' => Str::slug(Input::get('city')), 'delkey' => Str::random(32, 'alpha'), 'del_date' => date('y-m-d', strtotime('+2 months')));
         $room = new Room($new_room);
         if ($room->save()) {
             $upload_path = path('public') . Photo::$upload_path_room . $room->id;
             if (!File::exists($upload_path)) {
                 File::mkdir($upload_path);
                 chmod($upload_path, 0777);
             }
             $photos = Photo::getNormalizedFiles(Input::file('pictures'));
             foreach ($photos as $photo) {
                 $filename = md5(rand()) . '.jpg';
                 $path_to_file = $upload_path . '/' . $filename;
                 $dynamic_path = '/' . Photo::$upload_path_room . $room->id . '/' . $filename;
                 $success = Resizer::open($photo)->resize(800, 533, 'auto')->save($path_to_file, 80);
                 chmod($path_to_file, 0777);
                 if ($success) {
                     $new_photo = new Photo();
                     $new_photo->location = $dynamic_path;
                     $new_photo->room_id = $room->id;
                     $new_photo->save();
                 }
             }
             Message::send(function ($message) use($room) {
                 $message->to($room->email);
                 $message->from('kamers@kamergenood.nl', 'Kamergenood');
                 $message->subject('In afwachting op acceptatie: "' . $room->title . '"');
                 $message->body('view: emails.submit');
                 $message->body->id = $room->id;
                 $message->body->title = $room->title;
                 $message->body->price = $room->price;
                 $message->body->type = $room->type;
                 $message->body->surface = $room->surface;
                 $message->body->available = $room->available;
                 $message->body->description = $room->description;
                 $message->body->url = $room->url;
                 $message->body->delkey = $room->delkey;
                 $message->html(true);
             });
             if (Message::was_sent()) {
                 return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-success"><strong>Hartelijk dank voor het vertrouwen in Kamergenood!</strong> De kameradvertentie zal binnen 24 uur worden gecontroleerd en geplaatst.</div>');
             }
         } else {
             return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-error"><strong>Er is iets mis gegaan bij het toevoegen.</strong> Probeer het later nog eens.</div>')->with_input();
         }
     }
 }
开发者ID:sanneterpstra,项目名称:Kamergenood,代码行数:58,代码来源:rooms.php

示例11: testInsert

 public function testInsert()
 {
     $photo = new Photo();
     $photo->attributes = $_POST['Photo'];
     if ($photo->save()) {
         $this->photo_id = $photo->id;
         $this->assertEquals($_POST['Photo'], $photo->attributes);
     }
 }
开发者ID:sgaraba,项目名称:photo_gallery,代码行数:9,代码来源:PhotoTest.php

示例12: fetch

 function fetch($annee = NULL)
 {
     if (!$this->activite) {
         return array('activites' => $this->unite->findActivites($annee));
     } else {
         $this->controller->assert(null, $this->activite, 'envoyer-photo', "Vous n'avez pas le droit d'envoyer de photo de " . $this->activite->getIntituleComplet() . ".");
     }
     $m = new Wtk_Form_Model('envoyer');
     $i = $m->addString('titre', 'Titre');
     $m->addConstraintRequired($i);
     $m->addFile('photo', "Photo");
     $m->addString('commentaire', 'Votre commentaire');
     $m->addBool('envoyer', "J'ai d'autres photos à envoyer", true);
     $m->addNewSubmission('envoyer', "Envoyer");
     $t = new Photos();
     if ($m->validate()) {
         $p = new Photo();
         $p->titre = $m->titre;
         $p->slug = $t->createSlug(wtk_strtoid($m->titre));
         $p->activite = $this->activite->id;
         $action = $m->envoyer ? 'envoyer' : 'consulter';
         $c = new Commentaire();
         $c->auteur = Zend_Registry::get('individu')->id;
         $c->message = $m->commentaire;
         $db = $t->getAdapter();
         $db->beginTransaction();
         try {
             $c->save();
             $p->commentaires = $c->id;
             $p->save();
             $i = $m->getInstance('photo');
             if ($i->isUploaded()) {
                 $tmp = $i->getTempFilename();
                 $p->storeFile($tmp);
             }
             $url = $this->controller->_helper->Url('voir', 'photos', null, array('photo' => $p->slug), true);
             $this->controller->logger->info("Photo envoyée", $url);
             foreach ($this->activite->findUnitesParticipantesExplicites() as $u) {
                 $ident = new Identification();
                 $ident->photo = $p->id;
                 $ident->unite = $u->id;
                 $ident->save();
                 $this->controller->logger->info("Unité identifiée sur une photo", $url);
             }
             $db->commit();
         } catch (Exception $e) {
             $db->rollBack();
             throw $e;
         }
         $this->controller->_helper->Flash->info("Photo envoyée");
         $this->controller->redirectSimple($action, null, null, array('album' => $this->activite->slug));
     }
     $photos = $this->activite->findPhotos($t->select()->order('date'));
     return array('unite' => $this->unite, 'annee' => $annee, 'model' => $m, 'activite' => $this->activite, 'photos' => $photos);
 }
开发者ID:bersace,项目名称:strass,代码行数:55,代码来源:PhotosEnvoyer.php

示例13: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Photo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Photo'])) {
         $model->attributes = $_POST['Photo'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:sgaraba,项目名称:photo_gallery,代码行数:17,代码来源:PhotoController.php

示例14: converseToModel

 /**
  * Añade datos de la ultima foto cargda (Zend_Gdata_Photos_PhotoFeed)
  * al modelo Photo.
  *
  * @return Photo
  */
 public static function converseToModel()
 {
     $picasa = new Neo_Gdata_Photo();
     $photo = $picasa->getLastPhotoUpload();
     $foto = new Photo();
     $foto->photo_id = $photo->getGphotoId();
     $foto->titulo = $photo->getTitle();
     $foto->descripcion = $photo->getMediaGroup()->getDescription();
     $thumbnail = $photo->getMediaGroup()->getThumbnail();
     $foto->thumbnail_1 = $thumbnail[0]->getUrl();
     $foto->thumbnail_2 = $thumbnail[1]->getUrl();
     $foto->thumbnail_3 = $thumbnail[2]->getUrl();
     $foto->save();
     return $foto;
 }
开发者ID:Neozeratul,项目名称:Intermodels,代码行数:21,代码来源:Photo.php

示例15: addPhoto

 public function addPhoto($userId, $filePath)
 {
     $photo = new Photo();
     $photo->user_id = $userId;
     $photo->photo_album_id = $this->id;
     $photo->file_path = $filePath;
     $saved = $photo->save();
     if ($saved) {
         if (count($this->photos) === 1) {
             $this->saveAttributes(array('cover_photo_id' => $photo->id));
         }
         return $photo;
     }
     return null;
 }
开发者ID:jayrulez,项目名称:yiisns,代码行数:15,代码来源:PhotoAlbum.php


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