How to implement download video in laravel 5 - php

i've developed laravel MVC web app that has a downloaded video in a Download page so When ever i click on download button it should get me the video downloaded, but instead it opens in a new tab in my browser
here is my code:
Controller download function:
public function download($file_name) {
$file_path = public_path('download/'.$file_name);
return response()->download($file_path);
}
Download button :
Download

Related

PHP PDF download is not working properly in mobile

I am creating a web application in Codeigniter 4 in which users can purchase a PDF book. After payment, the user is redirected to a page where he/she can download PDF directly. The page doesn't have any UI. The PDF download is implemented using headers. The PDF download function is working perfectly on PC, but on mobile, the file is downloading as an HTML file.
eg : filename.pdf.html.
My function is as below
public function download()
{
$file_url = WRITEPATH . 'uploads/file.pdf';
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=filename.pdf");
readfile($file_url);
}
I have searched and tried almost all the solutions. But still, the issue is not resolved in mobile.
Solved the issue.
Looks like Codeigniter needed exit() function after readfile()
Thanks to #vee who gave the tip.

Laravel FFMpeg upload video and concat with request

i have problem when i upload video from (form HTML)
i use Laravel FFMpeg package
this code from my controller
$file = $request->file('video'); // take video request
FFMpeg::fromDisk('public')
->open(['vid\vid_one.mp4' , $file]) // concat video here and i think there is a problem
->export()
->concatWithoutTranscoding()
->save('contacct.mp4');
You have to store that video on that point where you are using ffmpeg open function with this function:
$request->file('video')->storeAs('folderName', $request->video->getClientOriginalName(), 'diskName');

Android app webview is not downloading or loading pdf, php mpdf

I have developed a page which display invoice in html and has a download link for PDF. I am using mpdf library- php. Here is my code for download link:
public function downloadInvoice()
{
$id = $this->uri->segment(2);
$where = array('invoice_id'=>$id);
$data['invoice'] = $this->Common_model->getDataWhere("invoices","*",$where);
$mpdf = new \Mpdf\Mpdf();
$this->session->set_userdata($data);
$filename = $invoice['invoice_no'].'.pdf';
header("Content-Disposition", "attachment; filename='.$filename.'");
$html=$this->load->view('user/pdf/download_invoice',[],true);
$mpdf->WriteHTML($html);
$mpdf->Output($filename, 'D');
}
I am able to download the pdf in each and every browser, event in mobile browser. The android app developer using this link in app and showing it in webview. Now he is saying that download link does nothing. I also asked him to try the download link directly . this is also not working. What change should I apply to make it work in mobile. Mobile developer is saying that he has no control on webview and cannot do anything from his side.
Please help.

Ajax download fpdf in codeigniter not working

Expected requirement - when user clicks button ajax will be call to controller where pdf will generate and generated pdf will gets downloaded on user's system.
Actual Scene - i able to create pdf using fpdf file and saved in folder and used force download function but nothing happend.
here's my code:
Controller :
$this->load->helper('download');
$this->load->library('myfpdf');
$this->load->view('pdf/namewise_report',[]);
$link = base_url().'uploads/pdfs/namewise.pdf';
force_download($link, NULL);
pdf/namewise_report.php (last line)
$this->myfpdf->Output('uploads/pdfs/namewise.pdf', "F");
is there anything to add in ajax success response

Facebook return an URL of image to download

I am trying to develop a login to my website functionality with Facebook account using Facebook Graph API.
I am in trouble to retrieve profile image of logged in user because Facebook returns URL but when I try it on the navigator it says that it needs permission to download it.
For example the URL:
https://platform-lookaside.fbsbx.com/platform/profilepic/?asid......
PS : I make the 3 points
I want to know if there is any method to get a correct URL to save it in the database or if there is any method to download the image with PHP, I tried this on my end, but no success.
$img = file_get_contents($dataata['picture']['url']);
$file = '/img/test.jpg';
file_put_contents($file, $img);
Message returned is :
file_put_contents(/img/test.jpg): failed to open stream: No such file
or directory
Any solution?

Categories