uploading images

This commit is contained in:
Ghostie 2024-08-20 20:06:52 -05:00
parent fa37868637
commit 3954144691
3 changed files with 14 additions and 2 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ yarn-error.log
/.fleet
/.idea
/.vscode
uploads

View File

@ -2,7 +2,9 @@
namespace App\Http\Controllers;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Intervention\Image\Laravel\Facades\Image;
class ImageController extends Controller
{
@ -10,6 +12,13 @@ class ImageController extends Controller
{
$image = $request->file("file");
return response()->json(["image" => $image->extension()]);
$nameImage = Str::uuid() . "." . $image->extension();
$imageServer = Image::read($image);
$imageServer->cover(1000, 1000);
$imagePath = public_path("uploads") . "/" . $nameImage;
$imageServer->save($imagePath);
return response()->json(["image" => $nameImage]);
}
}

View File

@ -12,4 +12,6 @@ const dropzone = new Dropzone("#dropzone", {
dropzone.on("sending", function (file, xhr, formData) {});
dropzone.on("success", function (file, response) {});
dropzone.on("success", function (file, response) {
console.log(response);
});