Category : download

I already tried with the following code. But the download file is corrupted, it’s showing "we don’t support this file format!" $fileName = $request->fileName; // $file_url = public_path() . "/uploads/$fileName"; $file_url = "https://helloworld.net". "/uploads/$fileName"; header(‘Content-Type: application/octet-stream’); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename="" . basename($file_url) . """); readfile($file_url); Sourc..

Read more

I am trying to store the file (resume) I receive from my input form into my assets folder, so I can download later. $applicant = new Applicant; $applicant->resume = $request->input(‘resume’); $filename = time().’.’. $applicant->resume->getClientOriginalExtension(); $request->resume->move(‘assets’, $filename); Sourc..

Read more

I have a function to add an image, and upon successful addition in the database, we have a path like public/images/asd.png. The question is how to make sure that when added to the name of the picture, an ID is added, and we have something like public/images/asd1.png, public/images/asd2.png, etc. function in Model public function getOriginImageUrl() ..

Read more

I’m using php version 7.3 and laravel 5.4 I’ve a controller function fetchUrls which returns a json response containing urls data public function fetchUrls($id) { $urlData = $this->service->fetchUrls($id); return $this->done(null, [ ‘url_data’ => $urlData ]); } Using this controller function in my routes Route::get(‘url-data/{id}’, ‘[email protected]’); When I hit this api http://localhost:8000/api/url-data/{1} The response looks like ..

Read more

I’ve read the documentation from spatie, but the result inside the zip is no files at all. Can anyone help me? use AppModelsProker; use SpatieMediaLibrarySupportMediaStream; use ZipStreamOptionArchive as ArchiveOptions; public function downloadProkers(Proker $prokers) { // Let’s get some media. $downloads = $prokers->getMedia(‘prokers’); // Download the files associated with the media in a streamed way. // ..

Read more

I have created controller in laravel which contains following code $doc = Document::find($id); if (Storage::disk(‘local’)->exists($doc->path)) { return Storage::disk(‘local’)->get($doc->path); } On Frontend I’m using javascript to programatically download the file with following code async downloadDocument() { DocService.downloadDoc(this.document.id).then((response) => { // Service that handles ajax call const url = window.URL.createObjectURL(new Blob([response.data])); const link = document.createElement("a"); link.href = ..

Read more

I have a function the program is generating a .csv file, and after I want to download in the browser. The problem is: when the function is called, the file is displaying in the browser instead of downloading it. Any suggestion? $csv=array($index,$value); $filename=’persons.xls’; $handle=fopen(‘persons.xls’, ‘w’); $headers = [‘Content-Type: text/xls’]; foreach ($csv as $row) { fputcsv($handle, ..

Read more

what is wrong with my code? when I watch the preview in inspect element in the browser, I can see the image in the preview section. but the image is not downloading. $name = $result[‘name’]; $path = $result[‘path’]; $disposition = HeaderUtils::makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $name, str_replace(‘%’, ”, Str::ascii($name))); return Response::download($path, $name, [ ‘Content-Type’ => ‘image/png’, ‘Content-Disposition’ => $disposition ..

Read more

I have a link for example "https://www.example.com/example-811.jpg" I need to upload it to laravel storage (../app/storage/public/). This is the maximum that I could implement in the controller, everything is fine, but the files are loaded in the TMP extension, how can I load the file in the required format? $filename = ‘example-811.jpg’; $tempImage = tempnam(‘..storageapppublic’, ..

Read more

use IlluminateHttpRequest; use PDF; class PDFController extends Controller { /** * Display a listing of the resource. * * @return IlluminateHttpResponse */ public function generatePDF() { $data = [ ‘title’ => ‘hello world’, ‘date’ => date(‘m/d/Y’) ]; $pdf = PDF::loadView(‘myPDF’, $data); return $pdf->download(‘itsolutionstuff.pdf’); } } Sourc..

Read more

i’m trying to download a file from s3 and i’m not getting any errors but the download is not happening, this is the way i’m saving files into the bucket: private function saveInvoice($documentPath, $code) { $filePath = "S3/Invoices/".Session::get(‘user’)."/$code.pdf"; $s3 = Storage::disk(‘s3_invoices’); $s3->put($filePath, $documentPath, ‘public’); return $filePath; } public function uploadFile (Request $request){ $file = $request->file(‘file’); ..

Read more

Currently, I am using the ZipArchive to zip a folder(which contains subfolder and files). In the local dev environment(Linux hosting), after I extract the zip file, the directory structure is correct. But when i deploy to production server(Window hosting), after I extract the zip file, the directory structure is incorrect. You can refer to the ..

Read more

I am using this ajax to pass my data from one view to pdf view in laravel. I am able to get data in the pdf preview but it unable to download from browser headers: { ‘X-CSRF-TOKEN’: $(‘meta[name="csrf-token"]’).attr(‘content’) }, url:"{{ route(‘monthlybilling.monthlybill’) }}", type:"GET", //dataType:"json", data:{ site:site, startdate:startdate, }, xhrFields: { responseType: ‘blob’ // to avoid ..

Read more

i have a function, admin to download the document that upload by customer. here is the controller to download file i have 5 file to download, but only 1 file get error when download readfile(doc.pdf): failed to open stream: Operation not permitted at this line readfile($file); public function downloaddocpdf($id, $file) { $file = ‘storage/uploads/file/’.$id.’/’.$file; header(‘Content-Description: ..

Read more