Jump to content

Archived

This topic is now archived and is closed to further replies.

spinFIRE

PHP Download

Recommended Posts

Hey!

I want to make or use a (free) script that does this:

I browse to the script, and have a form in which I can type an URL:
[code]http://www.example.com/100mbfile.zip[/code]

Press OK! - and then the server starts to download the file into:
[code]/home/download/100mbfile.zip[/code]

Can something like this be done, - eventually with a status page which shows percentage of current downloads, size, speed and so on  ??? ???

-Hope someone can help  ;)
-spinFIRE

Share this post


Link to post
Share on other sites
I'm not totally sure what it is that you're trying to do.  Are you trying to copy a file from the server to a new location?  If you type in http://www.example.com/file.zip the browser it is going to force the download and you'll get the file.  If you need to get a log of that you could connect to the server logs and count the amount of times it has been accessed.  If you're only trying to track downloads and have PHP handle the downloading there should be plenty of free scripts out there that handle file downloads.  It's not really all that difficult.

Share this post


Link to post
Share on other sites
Sorry, PHP cannot specify a local directory.  It is a server side scripting language only.  The status/size/speed will all have to be done with something like AJAX.

Share this post


Link to post
Share on other sites
Example:
When I am not at home, and doesn't have some HD space to save downloads on, I could use a browser and send the link to the server, and then it download it for me. When I get home, it lies in the /home/download/ folder - this was the idea..

-spinFIRE

Share this post


Link to post
Share on other sites
You should buy bigger hard drives = )

I'm not sure how to go about that but ober is correct about the size/status/etc.  PHP can fetch filesize and what not but that's as far as that goes.  As far as retrieving the file from a remote location and storing it on the server I would assume you could run a cron job to check every (x) minutes to see if the file exists and download it to a directory with read/write permissions.  That would probably cause some strain on the server depending on what you were downloading.

Share this post


Link to post
Share on other sites
main code would be along the lines of

<?php
$filecontent=file_get_contents($_POST['fileurl']);
$filename=$_POST['filename'];
$fp = fopen("$filename", "w");
fwrite($fp, $filecontent);
fclose($fp);
?>

but i'm unsure on the filename so would have to be fetched from a diffrent box as not sure how it would be possible as could be psaces and hiphans and dots and all so not even regex could delete the rest

Share this post


Link to post
Share on other sites
It's because I have a server at home, - so I would just go to the ip and the script, enter the URL, and when I get home, it's downloaded..

I've tried [url=http://irodov.nm.ru/wget4web/]http://irodov.nm.ru/wget4web/[/url] - but I want something in php (I can understand that  ;D)
@shocker-z: I will try that tomorrow ;)

-spinFIRE

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.