rashiqulrony/laravel-image-upload
Composer 安装命令:
composer require rashiqulrony/laravel-image-upload
包简介
Laravel image & file upload package with S3 support using Intervention Image.
README 文档
README
Media Uploader
imageupload is Basic image upload and thumbnail management package for laravel (version: laravel/framework: ^8.0|^9.0|^10.0|^11.0|^12.0).
It also includes file and image preview functionality.
Install
Via Composer
composer require rashiqulrony/laravel-image-upload
Publish config file
You should publish the config file with:
php artisan vendor:publish --provider="Rashiqulrony\LaravelImageUpload\Providers\AppServiceProvider" --tag=config
In config/imageupload.php config file you should set imageupload global path.
return [ /* |-------------------------------------------------------------------------- | Base Directory |-------------------------------------------------------------------------- | | base_dir stores all other directory inside storage folder of your laravel application by default | if you specify any name. all storage will be done inside that directory or name that you specified | */ 'base_dir' => null, /* |-------------------------------------------------------------------------- | Thumb Directory |-------------------------------------------------------------------------- | | thumb_dir creates another folder inside the directory as a "thumb" by default | you can change the name thumb to any other name you like. */ 'thumb_dir' => 'thumb', /* |-------------------------------------------------------------------------- | Timestamp Prefix |-------------------------------------------------------------------------- | | If timestamp_prefix is true then create a file with a timestamp to ignore the same name image replacement. Example: image-1658562981.png. | If timestamp_prefix is false then the script checks file exists or not if the file exists then add the time() prefix for the new file otherwise leave it as the file | name. */ 'timestamp_prefix' => false, /* |-------------------------------------------------------------------------- | Thumb Image Height Width |-------------------------------------------------------------------------- | | specify the thumb image ratio of height and weight by default it takes 300px X 300px */ 'image_thumb_height' => 300, 'image_thumb_width' => 300, /* |-------------------------------------------------------------------------- | Folder permission |-------------------------------------------------------------------------- | | path_permission , if you create a folder in your project then you can define your folder permission. | Example: null, 0755, 0777 */ 'path_permission' => 0777, ];
Configuration
Before using this, you must complete the following steps (if you want to use the default filesystem disk, which is public):
Change your env filesystem drive to this if you want to use public storage directory.
FILESYSTEM_DISK=public
Please make sure to link your storage before using this package
php artisan storage:link
Image Upload
Use this class
use Rashiqulrony\LaravelImageUpload\Uploader;
Using Controller for Image Upload
/**
* Upload an image with optional resizing and thumbnail creation.
*
* @param mixed $requestFile Uploaded file from the request.
* @param string $path Destination folder path.
* @param bool $thumb Generate thumbnail or not.
* @param string|null $name Optional custom filename.
* @param array $imageResize Resize dimensions [width, height].
* @param array $thumbResize Thumbnail dimensions [width, height].
* @return array Uploaded image information.
*/
return Uploader::imageUpload($request->image, $path, 1, $name, [300, 300], [200, 200]);
Response
{
"name": "1744802578-60164bb368db6.jpg",
"originalName": "60164bb368db6.jpg",
"size": 24418,
"ext": "jpg",
"url": "http://127.0.0.1:8000/storage/upload/1744802578-60164bb368db6.jpg",
"thumbUrl": "http://127.0.0.1:8000/storage/upload/thumb/1744802578-60164bb368db6.jpg"
}
Using Controller for video Upload
/**
* Upload a video file.
*
* @param mixed $requestFile Video file from request.
* @param string $path Destination path.
* @param string|null $name Optional custom filename.
* @return array Uploaded video file info.
*/
return Uploader::videoUpload($request->video, $path, $name);
Response
{
"name": "123.mp4",
"originalName": "Web 1st slide Without Text new 04-25.mp4",
"size": 709821,
"ext": "mp4",
"url": "http://127.0.0.1:8000/storage/upload/123.mp4"
}
Using Controller for File Upload
/**
* Upload any type of file.
*
* @param mixed $requestFile File from request.
* @param string $path Destination folder path.
* @param string|null $name Optional custom filename.
* @return array Uploaded file info.
*/
return Uploader::fileUpload($request->video, $path, $name);
Response
{
"name": "123.pdf",
"originalName": "Registration_Form.pdf",
"size": 1082270,
"ext": "pdf",
"url": "http://127.0.0.1:8000/storage/upload/123.pdf"
}
Using Controller for Upload Base64 Image Upload
/**
* Upload a base64-encoded image.
*
* @param string $base64 Base64 encoded image string.
* @param string $path Destination folder path.
* @param string|null $name Optional custom filename.
* @return array Uploaded image info.
*/
return Uploader::imageUploadBase64($request->base64data, $path, $name);
Response
{
"name": "image.png",
"url": "http://127.0.0.1:8000/storage/upload/image.png"
}
Using Controller for Delete Media or Any File
/**
* Delete a file and optionally its thumbnail.
*
* @param string $file File name.
* @param string $path File path.
* @param bool $thumb Whether to delete the thumbnail.
* @return bool Success status.
*/
return Uploader::mediaDelete($file, $path, 1);
Response
return true or false;
Using Controller for Remove a Directory or Folder
/**
* Delete an entire folder.
*
* @param string $path Folder path.
* @return bool Success status.
*/
return Uploader::removeDir($path);
Response
return true or false;
rashiqulrony/laravel-image-upload 适用场景与选型建议
rashiqulrony/laravel-image-upload 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 53 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「file uploader」 「Laravel Image Upload」 「RashiqulRony」 「Simple File and Image Uploader」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rashiqulrony/laravel-image-upload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rashiqulrony/laravel-image-upload 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rashiqulrony/laravel-image-upload 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An HTML5 upload field for the CMS and frontend forms.
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Smart file uploader for Laravel
Component of cdn uploader for Yii2 framework
Laravel Media Popup to upload/view the files
PMVC Plugin for File information
统计信息
- 总下载量: 53
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-16