Downloading Quesiton
Moderator: General Moderators
Downloading Quesiton
Hey again guys.
Sorry for all the questions, but I have another one.
I'm trying to figure out how to download a file (or tarball, thanks Feyd) from a website using PHP, but it's not working.
Could anyone give me some pointers?
Thanks
Sphenn
Sorry for all the questions, but I have another one.
I'm trying to figure out how to download a file (or tarball, thanks Feyd) from a website using PHP, but it's not working.
Could anyone give me some pointers?
Thanks
Sphenn
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
given the proper url file_get_contents() can often do the job. The output from the request will be in the return data.
Thanks Feyd, this gave me an idea that works somewhat. However, this causes a file to be created with an ".out" extension appended to the filename specified. Do you know if there's any way to remove this without renaming the file itself (which is doable, I just don't want to do it if I don't have to)
Thanks for all your help
Sphenn
Thanks for all your help
Sphenn
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
how are you using it? (post your code, remember
Code: Select all
tags! )I have this right now:
This gives me a file called:
asdf-101020030.zip.out
If I remove the .out extension, I have another zip file which then has the files that I want. Do you know of a way to get rid of the extension and the second zip package?
Thanks for your time
Sphenn
Code: Select all
<?php
$CVS = file_get_contents('http://cvs.sourceforge.net/cvstarballs/simplebb-cvsroot.tar.bz2');
$time = time();
file_put_contents('asdf-' . $time . 'zip', $CVS);
?>asdf-101020030.zip.out
If I remove the .out extension, I have another zip file which then has the files that I want. Do you know of a way to get rid of the extension and the second zip package?
Thanks for your time
Sphenn
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
running that locally gives me asdf-101020030zip
it needs to be named asdf-101020030.tar.bz2 or the file won't be read by most programs correctly..
What do you mean by "second zip package" ?
it needs to be named asdf-101020030.tar.bz2 or the file won't be read by most programs correctly..
Code: Select all
<?php
$CVS = file_get_contents('http://cvs.sourceforge.net/cvstarballs/simplebb-cvsroot.tar.bz2');
$time = time();
file_put_contents('asdf-' . $time . '.tar.bz2', $CVS);
?>What do you mean by "second zip package" ?
Oops, forgot the "." in the ext.
When I run this code, I get a file named: "asdf -1135253082.zip". If I extract this, I get a file named: "asdf-1135253082.zip.out". If I remove the ".out" extension, I get a zip archive which contains the files that I want to have. I don't know why this is happening.
Thanks for all of your help
Sphenn
Code: Select all
<?php
$CVS = file_get_contents('http://cvs.sourceforge.net/cvstarballs/simplebb-cvsroot.tar.bz2');
$time = time();
file_put_contents('asdf-' . $time . '.zip', $CVS);
?>Thanks for all of your help
Sphenn