fix upload

This commit is contained in:
mahdi purHosseini
2023-11-30 17:49:28 +03:30
parent d7dcbe37fa
commit dc019fec75
10 changed files with 26 additions and 7 deletions
+2 -7
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\UploadFileRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Intervention\Image\ImageManager;
@@ -10,15 +11,9 @@ use App\Media;
class UploadController extends Controller
{
public function uploadFile(Request $request)
public function uploadFile(UploadFileRequest $request)
{
$FileType = 'image';
$rules = [
"file" => "required|mimes:pdf,jpeg,png,jpg,doc,docx|max:2048",
"batch_id" => "required",
"model_type" => "required|string",
];
$this->validate($request, $rules);
if(substr( $request->file('file')->getMimeType(), 0, 12 ) == 'application/'){
$FileType = 'document';
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UploadFileRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
"file" => "required|mimes:pdf,jpeg,png,jpg,doc,docx|max:2048",
"batch_id" => "required",
"model_type" => "required|string",
];
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB