Reputation: 1919
my task is easy but I can't find anything on the web to help me.
I click on a button on my website, this event execute a php file (by ajax).
In this php file, I want to download a csv files directly on my serveur in the folder /uploads. I have the link of the csv, exemple : www.thewebsite.com/files/yourlastcall.csv
I have access to this folder, and I have all the rights in my /uploads.
So, do you guys know how to achieve this?
Thank you, and sorry for my english, i'm a little frenchy :)
Upvotes: 1
Views: 6306
Reputation: 1919
$url = 'http://website.com/linktofile.csv';
$source = file_get_contents($url);
file_put_contents('/path/to/file/newfilename.csv', $source);
thanks to Joel Hinz
Upvotes: 0
Reputation: 25384
Something like this, maybe?
$url = 'http://website.com/linktofile.csv';
$source = file_get_contents($url);
file_put_contents('/path/to/file/newfilename.csv', $source);
Edit: Of course, that's just the PHP part. I'm assuming you know how to make an AJAX call already, in jQuery or similarly.
Upvotes: 4