Category : file-upload

In postman there is an option to send binary datatype in a api. I am sending that in a api where but i am unable to detect that binary file in laravel request method. curl –location –request POST ‘http://192.168.*.*/api/v1/contact_us/save’ –header ‘Authorization: Bearer some_key’ –header ‘Content-Type: image/jpeg’ –data-binary ‘@/Users/username/Desktop/filename.jpeg’ Above is my curl code generated in ..

Read more

public function store(Request $request) { $request->validate([ ‘title’ => ‘required’, ‘description’ => ‘required’, ]); User::create($request->all()); return redirect()->route(‘Users.index’) ->with(‘success’,’User created successfully.’); } it is a resource controller , if there is a image that I want to upload I usually do this– public function store(Request $request) { $slider=new Slider(); $message="Slider not added successfully"; $slider->heading = $request->input(‘heading’); $slider->description ..

Read more

i’m trying to save an uploaded picture in the public/images directory. public function store(Request $request) { $request->validate([ ‘title’ => ‘required’, ‘description’ => ‘required’, ‘image’ => ‘required|image|mimes:jpg,png,jpeg|max:5048’ ]); $newImageName = uniqid() . ‘-‘ . $request->title . ‘.’ . $request->image->extension(); $request->image->move(public_path((‘images’), $newImageName)); Post::create([ ‘title’ => $request->input(‘title’), ‘description’ => $request->input(‘description’), ‘slug’ => SlugService::createSlug(Post::class, ‘slug’, $request->title), ‘image_path’ => $newImageName, ..

Read more

I’m struggling with the upload of files to a space i created for my app on digital ocean, i recieve this message error when i try to upload the file : Error executing "HeadObject" on "https://fichiers.fra1.digitaloceanspaces.com/fichier_documents/9"; AWS HTTP error: Client error: HEAD https://fichiers.fra1.digitaloceanspaces.com/fichier_documents/9 resulted in a 404 Not Found response NotFound (client): 404 Not Found ..

Read more

create.blade.php <div class="row mb-3"> <div class="col-md-12 mb-3"> <label for="body">Body</label> <textarea name="body" id="body" class="form-control"></textarea> </div> </div> <script src="{{ asset(‘themes/ckeditor/ckeditor.js’) }}"></script> <script> CKEDITOR.replace(‘body’ ,{ filebrowserUploadUrl : ‘/admin/upload/image’, filebrowserImageUploadUrl : ‘/admin/upload/image’ }); </script> web.php Route::post(‘/admin/upload/image’, ‘[email protected]’); AdminController.php public function upload() { $year = Carbon::now()->year; $imagePath = "/admin/upload/image/{$year}/"; $file = request()->file(‘upload’); $filename = $file->getClientOriginalName(); if (file_exists(public_path($imagePath).$filename)) { $filename = ..

Read more

this is my code in controller for insert data to database: public function store(Request $request) { $this->validate($request, [ ‘name’ => [‘required’, ‘max:255’], ‘info’ => [‘required’], ‘price’ => [‘required’, ‘max:255’], ‘image’ => [‘required’], ]); $ServiceData = [ ‘name’ => $request->name, ‘info’ => $request->info, ‘price’ => $request->price, ]; //store try { if ($request->hasFile(‘image’)) { $dest_path = ‘public/images/services’; ..

Read more

I want change image name follow the video id in Laravel project. How to solve this? Here is codes of controller $old_video = Video::find($id); //video thumbnail uploaded if ($request->hasFile(‘image_path’) != ”) { $video_themnull = $request->file(‘image_path’); $video_themnull_name = uniqid() . Str::random(’10’) . ‘.’ . $video_themnull->getClientOriginalExtension(); //$video_themnull_name = str_slug($id).’.’. $video_themnull->getClientOriginalExtension(); $video_themnull_resize = Image::make($video_themnull->getRealPath()); $video_themnull_resize->resize(400, 200); if ($video_themnull->isValid()) ..

Read more

I want change image name follow the video id in Laravel project. How to solve this? Here is codes of controller $old_video = Video::find($id); //video thumbnail uploaded if ($request->hasFile(‘image_path’) != ”) { $video_themnull = $request->file(‘image_path’); $video_themnull_name = uniqid() . Str::random(’10’) . ‘.’ . $video_themnull->getClientOriginalExtension(); $video_themnull_resize = Image::make($video_themnull->getRealPath()); $video_themnull_resize->resize(400, 200); if ($video_themnull->isValid()) { if (isset($old_video->image_path)) { ..

Read more

I am new to laravel. I am trying to upload multiple files, but when I try to upload the same filenames at the same time, it crashes. how to prevent uploading same image names. What I have tried is: Html code: <form method="POST" action="/listingSave" enctype="multipart/form-data" class="sellingFormSave" id="sellingFormSave" onsubmit="validate();"> <div class="row"> <div class="col-12 section_title-js"> <h3></h3> </div> ..

Read more

I keep getting this error "Creating default object from empty value" whenever I try uploading profile image when registering user, what I want to do is to upload to the image path "profile-photos/PP_1637044275.jpg" to the database, not the image name, any help will be appreciated. This is the Controller/action class class CreateNewUser implements CreatesNewUsers { ..

Read more

I have a form like this: <form action="{{ route(‘popups.store’) }}" method="POST" enctype="multipart/form-data"> @csrf <div id="dynamic_field"> <label>Date of showing</label> <input type="text" id="date" name="datep" class="form-control datepicker" value="" autofocus> <label for="title" class="control-label">Title</label> <input type="text" id="title" name="title" class="form-control" value="" autofocus> <label for="link" class="control-label">Link</label> <input type="text" id="link" name="linkp[]" class="form-control" value="" autofocus> <label for="bio" class="control-label">Text</label> <textarea class="form-control" name="bio[]" rows="3"></textarea> <label for="filep" ..

Read more

I wanted to upload an image so I coded this: public function store(Request $request) { try{ $data = $request->validate([ ‘datep’ => ‘nullable’, ‘title’ => ‘nullable’, ‘linkp’ => ‘nullable’, ‘matn’ => ‘nullable’, ‘filep’ => ‘nullable’, ]); $newImageName = time() . ‘-‘ . $request->name . ‘.’ . $request->filep->extension(); $request->filep->move(public_path(‘popups’), $newImageName); $newPop = Popup::create([ ‘datep’ => $data[‘datep’], ‘title’ ..

Read more

I’m having form which submits one file and certain texts through AJAX, only problem is with the file upload through AJAX. The form dats is being submitted through FormData instance but getting an Array to String conversion error while trying to save the file. I’m attaching the scripts below. Controller: public function store(Request $request) { ..

Read more

I cannot upload files using Laravel & AJAX and failing to understand why, when i’m checking for $request->hasFile(‘file_name’), I’m getting null however I’m getting the file path when i am dd ing $request->file_name. I’m attaching the required scripts. Controler: public function store(Request $request) { $request->validate([ ‘name’ => ‘required’, ‘contact_number’ => ‘required|numeric’, ’email’ => ‘required’, ‘total_exp’ ..

Read more