-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add editor upload-image functionality
- Loading branch information
Showing
10 changed files
with
135 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Storage; | ||
use Intervention\Image\Facades\Image; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class FileController extends Controller | ||
{ | ||
|
||
public function store(Request $request) | ||
{ | ||
|
||
$this->validate($request, [ | ||
'file' => 'image|required', | ||
]); | ||
|
||
$path = $request->file('file')->store('attachments'); | ||
|
||
Image::make(Storage::path($path)) | ||
->resize(1600, null, function ($constraint) { | ||
$constraint->aspectRatio(); | ||
$constraint->upsize(); | ||
}) | ||
->interlace() | ||
->save(); | ||
|
||
return response()->json([ | ||
'data' => [ | ||
'path' => Storage::url($path) | ||
] | ||
], Response::HTTP_CREATED); | ||
} | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"/js/app.js": "/js/app.js?id=93eee1c6f36a1eac2b6ae126a8161940", | ||
"/css/app.css": "/css/app.css?id=5aed6d56797605cc406c47f244b6234a" | ||
"/js/app.js": "/js/app.js?id=a081b725095ab293461ddd140bde7126", | ||
"/css/app.css": "/css/app.css?id=c96f213a8fd919bdba321ca0a4bd8bd0" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters