Upload PDF file to my server from a remote server

Viewed 42

I have the link to a PDF file from a remote server (A service sends me a link to my PDF invoice). Instead of saving the PDF file in my computer and then uploading the file to my server, I would like to have a link or form to save the file directly to my server. Is it possible?

1 Answers

You can use file_get_contents()

Your code will look like this

//save pdf on server
$file = file_get_contents('https://exploringjs.com/impatient-js/downloads/impatient-js-preview-book.pdf');
file_put_contents('impatient-js-preview-book.pdf', $file);

Pls don't forget to vote me up thanks

Related