alfiandri / imageupload
使用Laravel内置函数上传图片并自动调整大小。由Muhammad Zamroni提供。
Requires
- php: >=5.5.9
- intervention/image: ^2.4
- laravel/framework: ~5.2 || ^6.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- mockery/mockery: ^0.9.9
- orchestra/database: ~3.2
- orchestra/testbench: ~3.2
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-09-23 20:23:50 UTC
README
使用Laravel内置函数轻松上传图片并自动调整大小。
版本兼容性
旧版本遵循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 已不再支持
- 使用异常来提高错误处理能力
版本 7.0
- 添加 Laravel 6.0 的支持
版本 5.x 和 4.2.x
- 遵循 Laravel 版本命名的最后一个版本
- 使用 Imagine 库 的最后一个版本
下一个功能
- 利用 Laravel 的文件系统来存储上传的文件。
- 添加 Lumen 支持
许可证
MIT 许可证 (MIT)。更多详细信息,请参阅 许可证文件。