Download PDF files from a website and change the file name after downloading

I am trying to upload some files. I wrote a php script that can collect the entire address of the PDF files that I need to load into an array, but the file names on this server are odd. How can I upload pdf files using php?

+3
source share
2 answers

you can try (if I understood your question correctly)

file_put_contents('/your/file/name.pdf', 
    file_get_contents('http://www.example.com/oddFile.pdf'))
+3
source

Check the functions fileor file_get_contents. It can accept URLs as well as local file names.

http://www.php.net/manual/en/function.file.php

http://www.php.net/manual/en/function.file-get-contents.php

0
source

Source: https://habr.com/ru/post/1794978/


All Articles