This method works for most of the files, I only say most because I haven’t tried all. I have tried SWF flash and images, as I know it works well for both txt/ html files. I guess it will be okay even with pdf or some other file format, please leave a comment if it works for the format you have ben trying.
Access a file with php through it’s url and then write it into your ftp
$from_url=‘http://example.com/sample-file.swf’;
$location_to_write=‘/home/username/mysite.com/test.swf’;
$file_content=file_get_contents($from_url);
file_put_contents($location_to_write,$file_content);
Note:
- Use complete ftp address for the destination file name
- /home/username/mysite.com is just the way my host stores files, different hosts have different ways, your’s might use www/blah/public_html kind of navigation
Please leave a comment if it works for other formats or if it doesn’t work at all, that would help others too
- Permalink
- The Analyst
- 21 Jan 2010 6:19 AM
- Comments (0)