Category : file-upload

I will update the data its contain image, then when I will send to update here’s the error Call to a member function getClientOriginalName() This is my Controller public function updateBook(Request $request, $id){ $book = DB::table(‘books’)->where(‘id’,$id); $old = $book->select(‘images’); $ChecK = 0; $file = var_dump($request->file(‘images’)->getClientOriginalName()); $filename = time().$file; $path = public_path(‘/Uploads’); if($request->hasFile(‘images’)){ $file = $request->file(‘images’); ..

Read more

CONTROLLER public function store_resto(Request $request){ // dd($request->all()); $restaurant = new Restaurant(); $restaurant->name = $request->input(‘name’); $restaurant->email = $request->input(’email’); $restaurant->address = $request->input(‘address’); $restaurant->save(); $image = $request->hasfile(‘image’); $photo = rand(1,9999).’.’.$image; $path = public_path().’/files/’; $image->move($path, $photo); RestoImage::create([ ‘image’=>$image, ‘resto_id’=>$restaurant->id, ]); $request->session()->flash(‘status’, ‘Restaurant added successfully’); return redirect(‘list’); } VIEW FILE <form method="post" action="{{route(‘store_resto’)}}" enctype="multipart/form-data"> @csrf <div class="form-group"> <label>Resto Name</label> <input ..

Read more

I will show the upload image but it shown a thumbnail, here is my Controller Code Upload a image file $file = $request->file(‘images’)->getClientOriginalName(); $filename = time().$file; $path = base_path(‘/Uploads’); if($request->hasFile(‘images’)){ $file = $request->file(‘images’); $file->move($path, $filename); DB::table(‘books’)->insert($filename); return redirect(‘home’)->with(‘status’, ‘insert succesfully’); } else { dd(‘Request Hash No File!’); } Here is my view @foreach ($booksDTL as ..

Read more

Hi everyone I have this problem where I am not able to display the images that I have in the storage folder. I already connected the storage folder to the public one with the symlink (php artisan storage:link) but every time I try to visualize it I get this error from the console: "Failed to ..

Read more

I am trying to import data from excel file. when i upload .csv file using livewire it convert to .txt file. here is my modal code for importing file: <x-jet-modal maxWidth="sm" wire:model="showImportDialog"> <form wire:submit.prevent="import" method="POST" enctype="multipart/form-data"> <div> <div class="text-lg">Import Users</div> </div> <div> <input type="file" wire:model="users" name="users" id="users" /> </div> <x-jet-button type="submit">Import</x-jet-button> </form> </x-jet-modal> and this ..

Read more

I’m working on the file upload task. When I’m trying to upload a file on-page, it is throwing me the following error. I checked the syntax looks good. Can anyone help me in fixing this issue? Code if(array_key_exists(‘fileToUpload’, $request->all())) { $access_time = Carbon::now()->format(‘mdYHis’); $directory = storage_path() . "app/public/huntSchedule"; $files = $request->fileToUpload; $filename = $access_time.’_photo’.Auth::user()->id.’.’.$files->getClientOriginalExtension(); File::copy($files,$directory.’/’.$filename); ..

Read more

Getting this error after updating the image. Call to a member function getClientOriginalExtension() on string This is the before code. If I dd(); this code I get the file name with the extension but it’s a string. So I cannot get the original extension. $image = $request->warrantyUpload; $destination = public_path(‘/uploads/’); $ext = $image->getClientOriginalExtension(); $mainFilename = ..

Read more

In my laravel application, I’m trying to implement amazon s3 bucket for image uploadings. Laravel Framework 8.40 PHP 7.4.23 I tried this command, composer require league/flysystem-aws-s3-v3 ~1.0 But this kept giving me an error saying – aws/aws-sdk-php 3.173.9 requires guzzlehttp/psr7 ^1.4.1 -> satisfiable by guzzlehttp/psr7[1.4.1, 1.4.2, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.6.1, 1.7.0, 1.8.0, 1.8.1, 1.8.2, ..

Read more

Which is the best Scenario regarding performance, speed and best practices? 1- Upload Image to API endpoint using multipart-form data then send data to another API endpoint with the link of Image (in body) 2- Upload all data once in single API endpoint with multipart-form data I prefer (1) because I don’t want to use ..

Read more

I’m trying to upload a file to a php laravel server from an ionic react app. postData.append(‘image’, this.state.post_pic); if (this.state.usr_txt !== "") { postData.set(‘text’, this.state.usr_txt); } else { postData.set(‘type’, ‘image’); } the this.state.post_pic has the file object when appended file object The request is sent using axios as shown below: axios({ method: ‘post’, url: ‘/api/post’, ..

Read more

Just starting to work with File uploads in Laravel 8.x. I have a UI built and routes and a Controller, and I’m having an internal debate about where and how to store the files. The expectation is that the files will be .gif, .jpg, .png, .pdf, ?.docx, and possibly some video files types, but mostly ..

Read more

I would like to validate size of multiple files, and if size does not fit , i want to resize that single file, if size fit i upload it in original size. I have a few inputs on front: <div class="form-group"> <strong>SELECT MAIN IMAGE (required)</strong> <input type="file" name="files[fileMain]" id="fileMain" class="form-control-file border mb-1 {{ $errors->has(‘fileMain’) ? ..

Read more

This is my HTML code. <canvas id=’sig-canvas’ width=” height=’100%’></canvas> This is my ajax call. function signature(todo) { var canvas = document.getElementById("sig-canvas"); var pngUrl = canvas.toDataURL("image/png"); var sign = { img: pngUrl }; $.ajaxSetup({ headers: { ‘X-CSRF-TOKEN’: $(‘meta[name="csrf-token"]’).attr(‘content’) } }) $.ajax({ type: "POST", url: ‘/addSignature’, data: sign, // serializes the form’s elements. success: function (data) { ..

Read more

I try to create a simple file upload with Vuejs and Laravel. But my ‘b2b_file’ variable seems to be null. in Vue component I have: <b-form-file v-model="b2b_file" name="b2b_file" multiple > </b-form-file> methods: { this.b2b_file.map(element => { this.productData.b2b_file.push(element) }) } console.log(this.productData.b2b_file) returns the fallowing: https://prnt.sc/1hox1c5 Due to the path being empty in my controller when I ..

Read more