What is the best way to download something in php? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What is the best way to download something in php?

I am in search to find the best way to download something (image for example) which is in the same folder as the PHP file

14th Jul 2017, 10:46 PM
Αητοιπe
Αητοιπe - avatar
6 Answers
+ 10
you can try that link..
18th Jul 2017, 2:07 AM
Sarath Kumar
Sarath Kumar - avatar
+ 8
This link helpful for you.. https://www.javatpoint.com/php-tutorial All the best..
18th Jul 2017, 1:50 AM
Sarath Kumar
Sarath Kumar - avatar
+ 2
Thanks, I will see if I can an answer. On the precedent message, I said that I have find a download system with headers, there he is: header(“Content-description : File transfer”); header(“Content-type : application/octet-stream”); header(“Content-Disposition : attachment; filename = “. Nameofthefile); ob_clean(); readfile(“folder/”Nameofthefile);
18th Jul 2017, 2:03 AM
Αητοιπe
Αητοιπe - avatar
+ 2
I try to do this but it doesn't work: https://youtu.be/pZxv-5V0_Dg (in French)
18th Jul 2017, 2:04 AM
Αητοιπe
Αητοιπe - avatar
0
I think the reason you are not getting answers is that the question is not very clear. If you are trying to get the image from the server to your client browser, you only need an http request, not PHP. If you are trying to download an image to your computer, you should use an ftp protocol on the client side (probably what the browser is doing behind the scene). If you are trying to get the server to send you a file, you can probably do it with a combination of PHP (server) and FTP (transfer) but that would be weird. I think you will have more luck with your question if you clarify what you are trying to achieve and ask a more precise question.Good luck Antoine.
17th Jul 2017, 1:43 AM
Chadi Abdelhalim
0
Thank you for your answer, my question is about downloading files (IMG, text...)​from the same folder as the PHP file. I need for example, to click on a button (when the PHP file is open) and get (download on my computer) the file that I want to get. I have seen some download system using headers but I would like to know what's the best download system. I hope that my question is more comprehensive now. PS: if my English is not perfect, sorry, because I'm french
17th Jul 2017, 3:21 AM
Αητοιπe
Αητοιπe - avatar