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


PHP Photo::remove方法代码示例

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


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

示例1: updateAvatar

 public static function updateAvatar($db, $type_name, $type_id)
 {
     $res = array();
     $lokasi = public_path() . '/photos/';
     $cover_photo_id = '';
     // jika melakukan upload
     if (count($_FILES) > 0 && isset($_FILES)) {
         if (!empty($_FILES["cover_photo_id"]["tmp_name"])) {
             // Extension
             $ext = pathinfo($_FILES["cover_photo_id"]["name"], PATHINFO_EXTENSION);
             // cover photo tidak pernah di upload
             if (empty($db)) {
                 $post = new Photo();
                 $post->user_id = Auth::user()->id;
                 $post->type_name = $type_name;
                 $post->type_id = $type_id;
                 $post->status = 1;
                 $post->save();
                 $cover_photo_id = $post->id;
                 if (move_uploaded_file($_FILES["cover_photo_id"]["tmp_name"], $lokasi . $cover_photo_id . '.' . $ext)) {
                     $img = Image::make($lokasi . $cover_photo_id . '.' . $ext);
                     if ($ext != 'jpg') {
                         $img->encode('jpg', 75);
                         $img->save($lokasi . $cover_photo_id . '.jpg');
                     }
                     $img->fit(200);
                     $img->save($lokasi . 'thumb_' . $cover_photo_id . '.jpg');
                     // Menghapus file lama setelah kita meng-convert-nya ke jpg
                     if ($ext != 'jpg') {
                         if (file_exists($lokasi . $cover_photo_id . '.' . $ext)) {
                             unlink($lokasi . $cover_photo_id . '.' . $ext);
                         }
                     }
                 }
             } else {
                 $post = new Photo();
                 $post->user_id = Auth::user()->id;
                 $post->type_name = $type_name;
                 $post->type_id = $type_id;
                 $post->status = 1;
                 $post->save();
                 $cover_photo_id = $post->id;
                 if (move_uploaded_file($_FILES["cover_photo_id"]["tmp_name"], $lokasi . $cover_photo_id . '.' . $ext)) {
                     $img = Image::make($lokasi . $cover_photo_id . '.' . $ext);
                     if ($ext != 'jpg') {
                         $img->encode('jpg', 75);
                         $img->save($lokasi . $cover_photo_id . '.jpg');
                     }
                     $img->fit(200);
                     $img->save($lokasi . 'thumb_' . $cover_photo_id . '.jpg');
                     // Menghapus file lama setelah kita meng-convert-nya ke jpg
                     if ($ext != 'jpg') {
                         if (file_exists($lokasi . $cover_photo_id . '.' . $ext)) {
                             unlink($lokasi . $cover_photo_id . '.' . $ext);
                         }
                     }
                 }
                 // Removing the old file
                 Photo::remove($db);
             }
         } else {
             $cover_photo_id = $db;
         }
         $res = array('cover_photo_id' => $cover_photo_id);
         return $res;
     }
 }
开发者ID:whiterun,项目名称:bagikasih-v2,代码行数:67,代码来源:Photo.php

示例2: die

<?php

// $Id$
set_include_path(get_include_path() . ":../");
require_once "includes/session.php";
require_once "includes/utils.php";
require_once "includes/permissions.php";
require_once "includes/photo.php";
$session = Session::singletone();
if ($session->requireLogin()) {
    exit;
}
if (!Permissions::checkPerm('admin_panel')) {
    die("Permission denied.");
}
if (!Permissions::checkPerm('delete_photos')) {
    die("Permission denied.");
}
$ref = urldecode(Utils::pg("ref"));
$pid = urldecode(Utils::pg("pid"));
if (empty($pid)) {
    die;
}
$photo = new Photo($pid);
$photo->remove();
header("Location: {$ref}");
ini_restore('include_path');
开发者ID:BackupTheBerlios,项目名称:phphoto-svn,代码行数:27,代码来源:remove_photo.php

示例3: deleteDo

 /**
  * undocumented function
  *
  * @return void
  * @author 
  **/
 public function deleteDo()
 {
     $id = Input::get('id');
     $photo = Photo::remove($id);
     // Mengupdate semua fitur yang menggunakan foto menjadi 0
     Events::where('default_photo_id', $id)->update(['default_photo_id' => 0]);
     Events::where('cover_photo_id', $id)->update(['cover_photo_id' => 0]);
     SocialAction::where('default_photo_id', $id)->update(['default_photo_id' => 0]);
     SocialAction::where('cover_photo_id', $id)->update(['cover_photo_id' => 0]);
     SocialTarget::where('default_photo_id', $id)->update(['default_photo_id' => 0]);
     SocialTarget::where('cover_photo_id', $id)->update(['cover_photo_id' => 0]);
     if ($photo) {
         $lokasi = public_path() . '/photos/';
         if (unlink($lokasi . $id . '.jpg') && unlink($lokasi . 'thumb_' . $id . '.jpg')) {
             return Redirect::route('admin.photo')->withStatuses(['delete' => 'Hapus Sukses']);
         }
         return Redirect::route('admin.photo')->withErrors(['delete' => 'Delete File Gagal']);
     }
     return Redirect::route('admin.photo')->withErrors(['delete' => 'Delete File Gagal']);
 }
开发者ID:whiterun,项目名称:bagikasih-v2,代码行数:26,代码来源:AdminPhotoController.php


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