How to download PDF using PDF link with PHP - php

I want to know how to download file PDF from URL link or another source.
Example :
I have this link : www.nba.com/gamenotes/warriors.pdf if you click that link your browser automatically read the PDF and show the PDF or you can automatically download the PDF file using third party apps.
And i want to know a PHP code that download the PDF file from that link for example and save it to my computer

The idea is is
Load file from URL and then put content to user to download it.
file_put_contents("Tmpfile.zip", file_get_contents("http://someurl/file.zip"));
Try this
Download File to server from URL
http://4rapiddev.com/php/download-image-or-file-from-url/

Related

how can i restrict a file being viewed or downloaded using url? i want same file to be downloaded using php script

I want to restrict a pdf file on my server from being viewed or downloaded. for example, when somebody types below url in browser and press enter.
http://example.com/pdf/sample-pdf1.pdf
the file should not be viewed or downloaded. instead, it should get redirected somewhere else or should display some error message
But, when i download the same file using php or html code, it should get downloaded
for example when i use below code in a php file, it should get downloaded.
[a href="http://example.com/pdf/sample-pdf1.pdf" download]Download[/a]
Insert .htaccess file inside pdf directory with content:
"Deny from all" -
That will not allow access that directory and files inside it via URL.

Read an Excel file from a Link in PHP or CURL

I have a client project in which I have to read an excel file from following link:
https://app6.bosch.de/cgi-bin/WebObjects.dll/V5Prod_WES6.woa/39/wo/UpG9CtiiPkkyvA2ECwgqkg/41.0.1.3.21.1.1.9.9.0.2.27.3.17.7.1
Everytime a new link is generated, when we click on this link in normal site, it opens in a new tab an excel download option.
How to read the same file from my website using PHP (e.g. using curl)? I want to read this file and save it in my website directory automatically.

How to upload a pdf file to any information page in opencart2?

I need to find a way to upload a pdf file to my terms & services page in opencart2. I've looked for an extention, but the suitable extentsion are for opencart 1.5.x.
Is there a way to upload a pdf file and make it downloadable on the information page?
The easiest way would be to upload the file using FTP to a location within your website (e.g. the downloads subdirectory), then put a link to it on the information page using the information page editor. (e.g. http://www.tuinenmetgevoel.nl/downloads/myfile.pdf)

How to create View and Download Links for files on Amazon S3

I am developing an App which uploads files i.e. images,pdfs,text documents to Amazon S3. I am able to upload the files using S3.php class.
I have to store two links to the file in the database , the first link is the link to view the file in the browser if it is an image or a pdf document. The second link is to download the file.
I am able to generate the URL for each of the file using :
$url = $s3->getAuthenticatedUrl($bucket,$uri,$expiry)
But clicking the URL starts downloading the file, also this URL has an expiry time. But I have to store the links in database for longer time.
I also have to display the images and pdfs inside the browser, How can I generate the links. Kindly help...

Download Link not working in html

i am trying to make a download link in html that is given like this for a PDF Book
Download
but problem is that when download link is clicked it opens online version of pdf , does not offer download , i did google and found same way to add download link , any one can guide me with it please whats wrong here
As of late 2018, clicking the link won’t trigger a download if the resource to be downloaded wasn’t served from the same origin or same server. Apparently, this is restriction is a security measure.
You can download the content in browser and make it downloadable, you can check the below url
https://medium.com/charisol-community/downloading-resources-in-html5-a-download-may-not-work-as-expected-bf63546e2baa
you can try this
Download
HTML5 defines the download attribute, which forces the browser to prompt the user a download dialog for the resource instead of navigate to it.
Here is the support across the different browsers: http://caniuse.com/#feat=download.
Its not the problem with your script, instead its your browser that has pdf plug-in and displays you the content file directly.You can just save the page (Press CTRL+S) and it would be saved as .PDF file.
Thanks.
The HTML5 download attribute is only supported by Chrome and firefox... Try this :
Download
Download.php
header("Content-disposition: attachment; filename=http://www.mydomain.org/pdf/book.pdf");
header("Content-type: application/pdf:");
readfile("http://www.mydomain.org/pdf/book.pdf");
if you want to download the pdf in next tab with current website intact then use following code:
Download

Categories