0

HI,
I am writing a script in which i have to fetch a file and save it to the server on which the script is running . I have Googled it a lot but can not find how it can be done.

I once again try to explain, i want to get a file from a remote url to save on a server. Let us say that the file is text file located at some url exampleone.com/newpicture.jpg i want to download it to my site www.exampletwo.com

How can this be done.

Thanks in advance.

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by diafol
0

I think I already gave a solution to this using the php copy() function.

http://www.daniweb.com/forums/thread250236.html

Yeah i know but it is not working for me.. I have tried to send the url to the download.php file but it does not works.

Actually it is a dynamic url, i am looking for a solution, it is not compulsary that it should be solved in php.

I want to download the Google trends CVS to the webserver but when i give its url to your quoted download.php file nothing happens.

the url to Google trends csv is

www.google.com/trends/viz?q=check+it+out&graph=all_csv&scale=1&sa=N

Now i send it to download php like this

<?php
header("Location:download.php?file=www.google.com/trends/viz?q=check+it+out&graph=all_csv&scale=1&sa=N");
?>

but nothing happens and it gives error.. I will be really very very thankful if you can guide to a proper way.

Thanks

0

I think the problem with your request is that the google address doesn't point to a physical file - the querystring dynamically creates the file and forces a download. I'll have a look, but I'm not sure there is a simple solution.

//EDIT
How about this? It tells me that I have to be logged in to use it (the info within the file I mean).

<?php
$ch = curl_init("http://www.google.com/trends/viz?q=check+it+out&graph=all_csv&scale=1&sa=N");
$fp = fopen("googlecsv.csv", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);


?>

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.