本文整理汇总了PHP中Photo::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::add方法的具体用法?PHP Photo::add怎么用?PHP Photo::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: photo
static function photo($database, $plugins, $settings, $path, $albumID = 0, $description = '', $tags = '')
{
$info = getimagesize($path);
$size = filesize($path);
$photo = new Photo($database, $plugins, $settings, null);
$nameFile = array(array());
$nameFile[0]['name'] = $path;
$nameFile[0]['type'] = $info['mime'];
$nameFile[0]['tmp_name'] = $path;
$nameFile[0]['error'] = 0;
$nameFile[0]['size'] = $size;
if (!$photo->add($nameFile, $albumID, $description, $tags)) {
return false;
}
return true;
}
示例2: photo
static function photo($database, $plugins, $settings, $path, $albumID = 0, $description = '', $tags = '')
{
# No need to validate photo type and extension in this function.
# $photo->add will take care of it.
$info = getimagesize($path);
$size = filesize($path);
$photo = new Photo($database, $plugins, $settings, null);
$nameFile = array(array());
$nameFile[0]['name'] = $path;
$nameFile[0]['type'] = $info['mime'];
$nameFile[0]['tmp_name'] = $path;
$nameFile[0]['error'] = 0;
$nameFile[0]['size'] = $size;
if (!$photo->add($nameFile, $albumID, $description, $tags)) {
return false;
}
return true;
}
示例3: photo
/**
* Creates an array similar to a file upload array and adds the photo to Lychee.
* @return boolean Returns true when photo import was successful.
*/
private function photo($path, $albumID = 0)
{
// No need to validate photo type and extension in this function.
// $photo->add will take care of it.
$info = getimagesize($path);
$size = filesize($path);
$photo = new Photo(null);
$nameFile = array(array());
$nameFile[0]['name'] = $path;
$nameFile[0]['type'] = $info['mime'];
$nameFile[0]['tmp_name'] = $path;
$nameFile[0]['error'] = 0;
$nameFile[0]['size'] = $size;
$nameFile[0]['error'] = UPLOAD_ERR_OK;
if ($photo->add($nameFile, $albumID, true) === false) {
return false;
}
return true;
}
示例4: photo
private function photo($path, $albumID = 0, $description = '', $tags = '')
{
# Check dependencies
self::dependencies(isset($this->database, $this->plugins, $this->settings, $path));
# No need to validate photo type and extension in this function.
# $photo->add will take care of it.
$info = getimagesize($path);
$size = filesize($path);
$photo = new Photo($this->database, $this->plugins, $this->settings, null);
$nameFile = array(array());
$nameFile[0]['name'] = $path;
$nameFile[0]['type'] = $info['mime'];
$nameFile[0]['tmp_name'] = $path;
$nameFile[0]['error'] = 0;
$nameFile[0]['size'] = $size;
$nameFile[0]['error'] = UPLOAD_ERR_OK;
if (!$photo->add($nameFile, $albumID, $description, $tags, true)) {
return false;
}
return true;
}
示例5: upload
private function upload()
{
Module::dependencies(isset($_FILES, $_POST['albumID'], $_POST['tags']));
$photo = new Photo($this->database, $this->plugins, $this->settings, null);
echo $photo->add($_FILES, $_POST['albumID'], '', $_POST['tags']);
}
示例6: store
/**
* undocumented function
*
* @return void
* @author
**/
public function store()
{
$lokasi = public_path() . '/photos/';
$validator = $this->storeValid();
if ($validator->passes()) {
$input = $this->storeInput();
$photo = Photo::add($input);
$file = $_FILES['photo']['tmp_name'];
// Extension
$ext = pathinfo($_FILES["photo"]["name"], PATHINFO_EXTENSION);
if ($photo && move_uploaded_file($_FILES['photo']['tmp_name'], $lokasi . $photo->id . '.' . $ext)) {
$img = Image::make($lokasi . $photo->id . '.' . $ext);
if ($ext != 'jpg') {
$img->encode('jpg', 75);
$img->save($lokasi . $photo->id . '.jpg');
}
$img->fit(200);
$img->save($lokasi . 'thumb_' . $photo->id . '.jpg');
// Menghapus file lama setelah kita meng-convert-nya ke jpg
if ($ext != 'jpg') {
unlink($lokasi . $photo->id . '.' . $ext);
}
return Redirect::route('admin.photo')->withStatuses(['add' => 'Tambah Berhasil!']);
}
return Redirect::route('admin.photo.create')->withErrors(['add' => 'Tambah Gagal!'])->withInput();
}
return Redirect::route('admin.photo.create')->withErrors($validator)->withInput();
}