matriphe / imageupload
使用 Laravel 内置功能上传图像并自动调整大小。
Requires
- php: >=5.5.9
- intervention/image: ^2.4
- laravel/framework: ~5.2
Requires (Dev)
- mockery/mockery: ^0.9.9
- orchestra/database: ~3.2
- orchestra/testbench: ~3.2
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2020-11-11 05:55:01 UTC
README
使用 Laravel 内置功能轻松上传图像并自动调整大小。
版本兼容性
Laravel | Imageupload | 安装命令 |
---|---|---|
4.2.x | 4.x (已过时) | composer require "matriphe/imageupload:4.2.*" |
5.0.x / 5.1.x / 5.2.x / 5.3.x / 5.4.x | 5.x (稳定) | composer require "matriphe/imageupload:5.*" |
5.0.x / 5.1.x / 5.2.x / 5.3.x / 5.4.x | 6.0 | composer require "matriphe/imageupload:6.0" |
5.2.x / 5.3.x / 5.4.x / 5.5.x | 6.1.x (最新) | composer require "matriphe/imageupload:6.1.*" |
旧版本遵循 Laravel 版本。现在从版本 6.0 开始,此包将使用 语义版本 (semver)。
安装
打开 composer.json
并添加以下行。
"matriphe/imageupload": "6.*"
或者您可以直接在项目目录中运行此命令。
composer require "matriphe/imageupload"
Laravel 5.0, 5.1, 5.2, 5.3, 和 5.4
打开 config/app.php
并在 providers
部分添加此行。
Matriphe\Imageupload\ImageuploadServiceProvider::class,
仍然在 config/app.php
文件中,在 aliases
部分添加此行。
'Imageupload' => Matriphe\Imageupload\ImageuploadFacade::class,
Laravel 5.5
无需操作。它使用 Laravel 自动包发现功能。
发布配置和迁移文件
要控制配置,您必须发布配置文件。
php artisan vendor:publish --provider="Matriphe\Imageupload\ImageuploadServiceProvider"
运行此命令后,将会有 config/imageupload.php
配置文件和 database/migrations/2017_07_24_024410_create_image_upload_table.php
迁移文件。
配置
请检查 config/imageupload.php
获取更多详细信息。您可以使用 .env
根据您的环境进行配置。
如果您只想发布配置文件,运行此命令。
php artisan vendor:publish --provider="Matriphe\Imageupload\ImageuploadServiceProvider" --tag=imageupload-config
迁移
默认情况下,迁移文件将创建 image_uploads
表。检查文件并根据您的需求进行修改。
如果您只想发布迁移文件,运行此命令。
php artisan vendor:publish --provider="Matriphe\Imageupload\ImageuploadServiceProvider --tag=imageupload-migrations"
模型
您可以通过扩展 Matriphe\Imageupload\ImageuploadModel
来创建一个模型以扩展内置模型。请也检查此文件,并根据您的需求进行调整。
<?php namespace App; use Matriphe\Imageupload\ImageuploadModel; class Image extends ImageuploadModel { protected $table = 'images'; }
尝试上传一些内容!
发布配置文件后,您可以设置路由、视图并开始上传内容。
上传的文件将保存在 public/uploads
目录中。当然,您可以通过发布并修改配置文件来更改此设置。
确保存储上传文件的目录可写,并且可以被公众访问。
路由示例
<?php // routes.php Route::any('matriphe/imageupload', function() { $data = []; if (Request::hasFile('file')) { $data['result'] = Imageupload::upload(Request::file('file')); } return view('form.blade.php')->with($data); });
视图
请将此内容添加到您的视图目录中。
<!DOCTYPE html> <html> <head> <title>Imageupload</title> </head> <body> <form action="{{ URL::current() }}" method="post" enctype="multipart/form-data"> <input type="hidden" name="_token" value="{{ Session::token() }}"> <pre>{{ (!empty($result) ? print_r($result, 1) : '') }}</pre> <div> <input type="file" name="file"> </div> <div> <button type="submit">Upload!</button> </div> </form> </body> </html>
用法
只需使用 Imageupload::upload(Request::file('file'))
函数,它将处理裁剪和重命名。当然,您也可以通过传递参数 Imageupload::upload($filesource, $newfilename, $path)
在线修改。
函数的返回值是 Illuminate\Support\Collection
的实例。您可以使用 toArray()
或 toJson()
方法轻松将其转换为数组或 JSON。
设置输出
要动态更改输出,请在调用 upload($request)
之前使用 output($output)
方法。选项包括 collection
、json
、db
和 array
(默认)。请参阅配置文件以设置默认输出。
db
选项将自动将输出保存到数据库,并返回 Matriphe\Imageupload\ImageuploadModel
对象。
示例
if (Request::hasFile('file')) { $result = Imageupload::upload(Request::file('file')); } if (Request::hasFile('file')) { $result = Imageupload::output('json')->upload(Request::file('file')); }
输出示例
JSON
{ "original_filename":"IMG_20170619_195131.jpg", "original_filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131.jpg", "original_filedir":"uploads\/images\/IMG_20170619_195131.jpg", "original_extension":"jpg", "original_mime":"image\/jpeg", "original_filesize":1379716, "original_width":2592, "original_height":4608, "exif":{ "FileName":"phpPfn2JP", "FileDateTime":1500894790, "FileSize":1379716, "FileType":2, "MimeType":"image\/jpeg", "SectionsFound":"ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP", "COMPUTED":{ "html":"width=\"2592\" height=\"4608\"", "Height":4608, "Width":2592, "IsColor":1, "ByteOrderMotorola":1, "ApertureFNumber":"f\/2.0", "Thumbnail.FileType":2, "Thumbnail.MimeType":"image\/jpeg" }, "Make":"Xiaomi", "Model":"Redmi Note3", "XResolution":"72\/1", "YResolution":"72\/1", "ResolutionUnit":2, "Software":"kenzo-user 6.0.1 MMB29M 7.6.7 release-keys", "DateTime":"2017:06:19 19:51:31", "YCbCrPositioning":1, "Exif_IFD_Pointer":234, "GPS_IFD_Pointer":718, "THUMBNAIL":{ "Compression":6, "XResolution":"72\/1", "YResolution":"72\/1", "ResolutionUnit":2, "JPEGInterchangeFormat":898, "JPEGInterchangeFormatLength":15696 }, "ExposureTime":"1\/33", "FNumber":"200\/100", "ExposureProgram":0, "ISOSpeedRatings":854, "ExifVersion":"0220", "DateTimeOriginal":"2017:06:19 19:51:31", "DateTimeDigitized":"2017:06:19 19:51:31", "ComponentsConfiguration":"\u0001\u0002\u0003\u0000", "ShutterSpeedValue":"5058\/1000", "ApertureValue":"200\/100", "BrightnessValue":"300\/100", "MeteringMode":1, "Flash":16, "FocalLength":"357\/100", "SubSecTime":"123298", "SubSecTimeOriginal":"123298", "SubSecTimeDigitized":"123298", "FlashPixVersion":"0100", "ColorSpace":1, "ExifImageWidth":2592, "ExifImageLength":4608, "InteroperabilityOffset":687, "SensingMethod":2, "SceneType":"\u0001", "ExposureMode":0, "WhiteBalance":0, "FocalLengthIn35mmFilm":4, "SceneCaptureType":0, "GPSAltitudeRef":"200\/100", "GPSTimeStamp":[ "12\/1", "51\/1", "30\/1" ], "GPSDateStamp":"2017:06:19", "InterOperabilityIndex":"R98", "InterOperabilityVersion":"0100" }, "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images", "filename":"IMG_20170619_195131.jpg", "basename":"IMG_20170619_195131", "dimensions":{ "square50":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_square50.jpg", "filename":"IMG_20170619_195131_square50.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_square50.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_square50.jpg", "width":50, "height":50, "filesize":1379716, "is_squared":true }, "square100":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_square100.jpg", "filename":"IMG_20170619_195131_square100.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_square100.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_square100.jpg", "width":100, "height":100, "filesize":1379716, "is_squared":true }, "square200":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_square200.jpg", "filename":"IMG_20170619_195131_square200.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_square200.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_square200.jpg", "width":200, "height":200, "filesize":1379716, "is_squared":true }, "square400":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_square400.jpg", "filename":"IMG_20170619_195131_square400.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_square400.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_square400.jpg", "width":400, "height":400, "filesize":1379716, "is_squared":true }, "size50":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_size50.jpg", "filename":"IMG_20170619_195131_size50.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_size50.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_size50.jpg", "width":28, "height":50, "filesize":1379716, "is_squared":false }, "size100":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_size100.jpg", "filename":"IMG_20170619_195131_size100.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_size100.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_size100.jpg", "width":56, "height":100, "filesize":1379716, "is_squared":false }, "size200":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_size200.jpg", "filename":"IMG_20170619_195131_size200.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_size200.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_size200.jpg", "width":112, "height":200, "filesize":1379716, "is_squared":false }, "size400":{ "path":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images", "dir":"uploads\/images\/IMG_20170619_195131_size400.jpg", "filename":"IMG_20170619_195131_size400.jpg", "filepath":"\/Volumes\/data\/Development\/php\/laravel\/51\/public\/uploads\/images\/IMG_20170619_195131_size400.jpg", "filedir":"uploads\/images\/IMG_20170619_195131_size400.jpg", "width":225, "height":400, "filesize":1379716, "is_squared":false } } }
数组
Array
(
[original_filename] => IMG_20170619_195131.jpg
[original_filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131.jpg
[original_filedir] => uploads/images/IMG_20170619_195131.jpg
[original_extension] => jpg
[original_mime] => image/jpeg
[original_filesize] => 1379716
[original_width] => 2592
[original_height] => 4608
[exif] => Array
(
[FileName] => phpPfn2JP
[FileDateTime] => 1500894790
[FileSize] => 1379716
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP
[COMPUTED] => Array
(
[html] => width="2592" height="4608"
[Height] => 4608
[Width] => 2592
[IsColor] => 1
[ByteOrderMotorola] => 1
[ApertureFNumber] => f/2.0
[Thumbnail.FileType] => 2
[Thumbnail.MimeType] => image/jpeg
)
[Make] => Xiaomi
[Model] => Redmi Note3
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[Software] => kenzo-user 6.0.1 MMB29M 7.6.7 release-keys
[DateTime] => 2017:06:19 19:51:31
[YCbCrPositioning] => 1
[Exif_IFD_Pointer] => 234
[GPS_IFD_Pointer] => 718
[THUMBNAIL] => Array
(
[Compression] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[JPEGInterchangeFormat] => 898
[JPEGInterchangeFormatLength] => 15696
)
[ExposureTime] => 1/33
[FNumber] => 200/100
[ExposureProgram] => 0
[ISOSpeedRatings] => 854
[ExifVersion] => 0220
[DateTimeOriginal] => 2017:06:19 19:51:31
[DateTimeDigitized] => 2017:06:19 19:51:31
[ComponentsConfiguration] => ���
[ShutterSpeedValue] => 5058/1000
[ApertureValue] => 200/100
[BrightnessValue] => 300/100
[MeteringMode] => 1
[Flash] => 16
[FocalLength] => 357/100
[SubSecTime] => 123298
[SubSecTimeOriginal] => 123298
[SubSecTimeDigitized] => 123298
[FlashPixVersion] => 0100
[ColorSpace] => 1
[ExifImageWidth] => 2592
[ExifImageLength] => 4608
[InteroperabilityOffset] => 687
[SensingMethod] => 2
[SceneType] => �
[ExposureMode] => 0
[WhiteBalance] => 0
[FocalLengthIn35mmFilm] => 4
[SceneCaptureType] => 0
[GPSAltitudeRef] => 200/100
[GPSTimeStamp] => Array
(
[0] => 12/1
[1] => 51/1
[2] => 30/1
)
[GPSDateStamp] => 2017:06:19
[InterOperabilityIndex] => R98
[InterOperabilityVersion] => 0100
)
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images
[filename] => IMG_20170619_195131.jpg
[basename] => IMG_20170619_195131
[dimensions] => Array
(
[square50] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_square50.jpg
[filename] => IMG_20170619_195131_square50.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square50.jpg
[filedir] => uploads/images/IMG_20170619_195131_square50.jpg
[width] => 50
[height] => 50
[filesize] => 1379716
[is_squared] => 1
)
[square100] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_square100.jpg
[filename] => IMG_20170619_195131_square100.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square100.jpg
[filedir] => uploads/images/IMG_20170619_195131_square100.jpg
[width] => 100
[height] => 100
[filesize] => 1379716
[is_squared] => 1
)
[square200] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_square200.jpg
[filename] => IMG_20170619_195131_square200.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square200.jpg
[filedir] => uploads/images/IMG_20170619_195131_square200.jpg
[width] => 200
[height] => 200
[filesize] => 1379716
[is_squared] => 1
)
[square400] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_square400.jpg
[filename] => IMG_20170619_195131_square400.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square400.jpg
[filedir] => uploads/images/IMG_20170619_195131_square400.jpg
[width] => 400
[height] => 400
[filesize] => 1379716
[is_squared] => 1
)
[size50] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_size50.jpg
[filename] => IMG_20170619_195131_size50.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size50.jpg
[filedir] => uploads/images/IMG_20170619_195131_size50.jpg
[width] => 28
[height] => 50
[filesize] => 1379716
[is_squared] =>
)
[size100] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_size100.jpg
[filename] => IMG_20170619_195131_size100.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size100.jpg
[filedir] => uploads/images/IMG_20170619_195131_size100.jpg
[width] => 56
[height] => 100
[filesize] => 1379716
[is_squared] =>
)
[size200] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_size200.jpg
[filename] => IMG_20170619_195131_size200.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size200.jpg
[filedir] => uploads/images/IMG_20170619_195131_size200.jpg
[width] => 112
[height] => 200
[filesize] => 1379716
[is_squared] =>
)
[size400] => Array
(
[path] => /Volumes/data/Development/php/laravel/51/public/uploads/images
[dir] => uploads/images/IMG_20170619_195131_size400.jpg
[filename] => IMG_20170619_195131_size400.jpg
[filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size400.jpg
[filedir] => uploads/images/IMG_20170619_195131_size400.jpg
[width] => 225
[height] => 400
[filesize] => 1379716
[is_squared] =>
)
)
)
集合
Illuminate\Support\Collection Object ( [items:protected] => Array ( [original_filename] => IMG_20170619_195131.jpg [original_filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131.jpg [original_filedir] => uploads/images/IMG_20170619_195131.jpg [original_extension] => jpg [original_mime] => image/jpeg [original_filesize] => 1379716 [original_width] => 2592 [original_height] => 4608 [exif] => Array ( [FileName] => phpGacSlt [FileDateTime] => 1500895792 [FileSize] => 1379716 [FileType] => 2 [MimeType] => image/jpeg [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP [COMPUTED] => Array ( [html] => width="2592" height="4608" [Height] => 4608 [Width] => 2592 [IsColor] => 1 [ByteOrderMotorola] => 1 [ApertureFNumber] => f/2.0 [Thumbnail.FileType] => 2 [Thumbnail.MimeType] => image/jpeg ) [Make] => Xiaomi [Model] => Redmi Note3 [XResolution] => 72/1 [YResolution] => 72/1 [ResolutionUnit] => 2 [Software] => kenzo-user 6.0.1 MMB29M 7.6.7 release-keys [DateTime] => 2017:06:19 19:51:31 [YCbCrPositioning] => 1 [Exif_IFD_Pointer] => 234 [GPS_IFD_Pointer] => 718 [THUMBNAIL] => Array ( [Compression] => 6 [XResolution] => 72/1 [YResolution] => 72/1 [ResolutionUnit] => 2 [JPEGInterchangeFormat] => 898 [JPEGInterchangeFormatLength] => 15696 ) [ExposureTime] => 1/33 [FNumber] => 200/100 [ExposureProgram] => 0 [ISOSpeedRatings] => 854 [ExifVersion] => 0220 [DateTimeOriginal] => 2017:06:19 19:51:31 [DateTimeDigitized] => 2017:06:19 19:51:31 [ComponentsConfiguration] => ��� [ShutterSpeedValue] => 5058/1000 [ApertureValue] => 200/100 [BrightnessValue] => 300/100 [MeteringMode] => 1 [Flash] => 16 [FocalLength] => 357/100 [SubSecTime] => 123298 [SubSecTimeOriginal] => 123298 [SubSecTimeDigitized] => 123298 [FlashPixVersion] => 0100 [ColorSpace] => 1 [ExifImageWidth] => 2592 [ExifImageLength] => 4608 [InteroperabilityOffset] => 687 [SensingMethod] => 2 [SceneType] => � [ExposureMode] => 0 [WhiteBalance] => 0 [FocalLengthIn35mmFilm] => 4 [SceneCaptureType] => 0 [GPSAltitudeRef] => 200/100 [GPSTimeStamp] => Array ( [0] => 12/1 [1] => 51/1 [2] => 30/1 ) [GPSDateStamp] => 2017:06:19 [InterOperabilityIndex] => R98 [InterOperabilityVersion] => 0100 ) [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images [filename] => IMG_20170619_195131.jpg [basename] => IMG_20170619_195131 [dimensions] => Array ( [square50] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_square50.jpg [filename] => IMG_20170619_195131_square50.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square50.jpg [filedir] => uploads/images/IMG_20170619_195131_square50.jpg [width] => 50 [height] => 50 [filesize] => 1379716 [is_squared] => 1 ) [square100] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_square100.jpg [filename] => IMG_20170619_195131_square100.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square100.jpg [filedir] => uploads/images/IMG_20170619_195131_square100.jpg [width] => 100 [height] => 100 [filesize] => 1379716 [is_squared] => 1 ) [square200] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_square200.jpg [filename] => IMG_20170619_195131_square200.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square200.jpg [filedir] => uploads/images/IMG_20170619_195131_square200.jpg [width] => 200 [height] => 200 [filesize] => 1379716 [is_squared] => 1 ) [square400] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_square400.jpg [filename] => IMG_20170619_195131_square400.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_square400.jpg [filedir] => uploads/images/IMG_20170619_195131_square400.jpg [width] => 400 [height] => 400 [filesize] => 1379716 [is_squared] => 1 ) [size50] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_size50.jpg [filename] => IMG_20170619_195131_size50.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size50.jpg [filedir] => uploads/images/IMG_20170619_195131_size50.jpg [width] => 28 [height] => 50 [filesize] => 1379716 [is_squared] => ) [size100] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_size100.jpg [filename] => IMG_20170619_195131_size100.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size100.jpg [filedir] => uploads/images/IMG_20170619_195131_size100.jpg [width] => 56 [height] => 100 [filesize] => 1379716 [is_squared] => ) [size200] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_size200.jpg [filename] => IMG_20170619_195131_size200.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size200.jpg [filedir] => uploads/images/IMG_20170619_195131_size200.jpg [width] => 112 [height] => 200 [filesize] => 1379716 [is_squared] => ) [size400] => Array ( [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images/IMG_20170619_195131_size400.jpg [filename] => IMG_20170619_195131_size400.jpg [filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131_size400.jpg [filedir] => uploads/images/IMG_20170619_195131_size400.jpg [width] => 225 [height] => 400 [filesize] => 1379716 [is_squared] => ) ) ) )
ImageuploadModel
Matriphe\Imageupload\ImageuploadModel Object ( [thumbnailKeys:protected] => Array ( [0] => path [1] => dir [2] => filename [3] => filepath [4] => filedir [5] => width [6] => height [7] => filesize ) [fillable:protected] => Array ( [0] => original_filename [1] => original_filepath [2] => original_filedir [3] => original_extension [4] => original_mime [5] => original_filesize [6] => original_width [7] => original_height [8] => path [9] => dir [10] => filename [11] => basename [12] => exif ) [connection:protected] => [table:protected] => image_uploads [primaryKey:protected] => id [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [original_filename] => IMG_20170619_195131.jpg [original_filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131.jpg [original_filedir] => uploads/images/IMG_20170619_195131.jpg [original_extension] => jpg [original_mime] => image/jpeg [original_filesize] => 1379716 [original_width] => 2592 [original_height] => 4608 [exif] => {"FileName":"php19qj3X","FileDateTime":1500906046,"FileSize":1379716,"FileType":2,"MimeType":"image\/jpeg","SectionsFound":"ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP","COMPUTED":{"html":"width=\"2592\" height=\"4608\"","Height":4608,"Width":2592,"IsColor":1,"ByteOrderMotorola":1,"ApertureFNumber":"f\/2.0","Thumbnail.FileType":2,"Thumbnail.MimeType":"image\/jpeg"},"Make":"Xiaomi","Model":"Redmi Note3","XResolution":"72\/1","YResolution":"72\/1","ResolutionUnit":2,"Software":"kenzo-user 6.0.1 MMB29M 7.6.7 release-keys","DateTime":"2017:06:19 19:51:31","YCbCrPositioning":1,"Exif_IFD_Pointer":234,"GPS_IFD_Pointer":718,"THUMBNAIL":{"Compression":6,"XResolution":"72\/1","YResolution":"72\/1","ResolutionUnit":2,"JPEGInterchangeFormat":898,"JPEGInterchangeFormatLength":15696},"ExposureTime":"1\/33","FNumber":"200\/100","ExposureProgram":0,"ISOSpeedRatings":854,"ExifVersion":"0220","DateTimeOriginal":"2017:06:19 19:51:31","DateTimeDigitized":"2017:06:19 19:51:31","ComponentsConfiguration":"\u0001\u0002\u0003\u0000","ShutterSpeedValue":"5058\/1000","ApertureValue":"200\/100","BrightnessValue":"300\/100","MeteringMode":1,"Flash":16,"FocalLength":"357\/100","SubSecTime":"123298","SubSecTimeOriginal":"123298","SubSecTimeDigitized":"123298","FlashPixVersion":"0100","ColorSpace":1,"ExifImageWidth":2592,"ExifImageLength":4608,"InteroperabilityOffset":687,"SensingMethod":2,"SceneType":"\u0001","ExposureMode":0,"WhiteBalance":0,"FocalLengthIn35mmFilm":4,"SceneCaptureType":0,"GPSAltitudeRef":"200\/100","GPSTimeStamp":["12\/1","51\/1","30\/1"],"GPSDateStamp":"2017:06:19","InterOperabilityIndex":"R98","InterOperabilityVersion":"0100"} [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images [filename] => IMG_20170619_195131.jpg [basename] => IMG_20170619_195131 [updated_at] => 2017-07-24 21:20:53 [created_at] => 2017-07-24 21:20:53 [id] => 1 ) [original:protected] => Array ( [original_filename] => IMG_20170619_195131.jpg [original_filepath] => /Volumes/data/Development/php/laravel/51/public/uploads/images/IMG_20170619_195131.jpg [original_filedir] => uploads/images/IMG_20170619_195131.jpg [original_extension] => jpg [original_mime] => image/jpeg [original_filesize] => 1379716 [original_width] => 2592 [original_height] => 4608 [exif] => {"FileName":"php19qj3X","FileDateTime":1500906046,"FileSize":1379716,"FileType":2,"MimeType":"image\/jpeg","SectionsFound":"ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP","COMPUTED":{"html":"width=\"2592\" height=\"4608\"","Height":4608,"Width":2592,"IsColor":1,"ByteOrderMotorola":1,"ApertureFNumber":"f\/2.0","Thumbnail.FileType":2,"Thumbnail.MimeType":"image\/jpeg"},"Make":"Xiaomi","Model":"Redmi Note3","XResolution":"72\/1","YResolution":"72\/1","ResolutionUnit":2,"Software":"kenzo-user 6.0.1 MMB29M 7.6.7 release-keys","DateTime":"2017:06:19 19:51:31","YCbCrPositioning":1,"Exif_IFD_Pointer":234,"GPS_IFD_Pointer":718,"THUMBNAIL":{"Compression":6,"XResolution":"72\/1","YResolution":"72\/1","ResolutionUnit":2,"JPEGInterchangeFormat":898,"JPEGInterchangeFormatLength":15696},"ExposureTime":"1\/33","FNumber":"200\/100","ExposureProgram":0,"ISOSpeedRatings":854,"ExifVersion":"0220","DateTimeOriginal":"2017:06:19 19:51:31","DateTimeDigitized":"2017:06:19 19:51:31","ComponentsConfiguration":"\u0001\u0002\u0003\u0000","ShutterSpeedValue":"5058\/1000","ApertureValue":"200\/100","BrightnessValue":"300\/100","MeteringMode":1,"Flash":16,"FocalLength":"357\/100","SubSecTime":"123298","SubSecTimeOriginal":"123298","SubSecTimeDigitized":"123298","FlashPixVersion":"0100","ColorSpace":1,"ExifImageWidth":2592,"ExifImageLength":4608,"InteroperabilityOffset":687,"SensingMethod":2,"SceneType":"\u0001","ExposureMode":0,"WhiteBalance":0,"FocalLengthIn35mmFilm":4,"SceneCaptureType":0,"GPSAltitudeRef":"200\/100","GPSTimeStamp":["12\/1","51\/1","30\/1"],"GPSDateStamp":"2017:06:19","InterOperabilityIndex":"R98","InterOperabilityVersion":"0100"} [path] => /Volumes/data/Development/php/laravel/51/public/uploads/images [dir] => uploads/images [filename] => IMG_20170619_195131.jpg [basename] => IMG_20170619_195131 [updated_at] => 2017-07-24 21:20:53 [created_at] => 2017-07-24 21:20:53 [id] => 1 ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [dateFormat:protected] => [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => 1 [wasRecentlyCreated] => 1 )
更新日志
版本 6.1
- 支持输出类型
json
、array
、collection
和db
- 添加对使用
output()
方法更改输出类型的支持 - 移除对 Laravel 5.0 和 5.1 的支持
版本 6.0
- 开始使用 语义版本(semver) 进行版本控制
- 使用 Intervention 进行图像处理
- 仅支持 GD 和 Imagick (ImageMagick),不再支持 Gmagick
- 使用异常进行更好的错误处理
版本 5.x 和 4.2.x
- 遵循 Laravel 版本控制的最后一个版本
- 使用 Imagine 库 的最后一个版本
下一功能
- 使用Laravel文件系统来存储上传的文件。
- 添加Lumen支持
许可协议
MIT许可协议(MIT)。请参阅许可文件以获取更多信息。