Jump to content


Photo

PHP Download


  • Please log in to reply
6 replies to this topic

#1 spinFIRE

spinFIRE
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 September 2006 - 06:59 PM

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:
http://www.example.com/100mbfile.zip

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

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

#2 gijew

gijew
  • Members
  • PipPipPip
  • Advanced Member
  • 240 posts
  • LocationCalifornia

Posted 12 September 2006 - 07:19 PM

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.
I'm considered good looking in some countries

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 12 September 2006 - 07:20 PM

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.

Info: PHP Manual


#4 spinFIRE

spinFIRE
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 September 2006 - 07:22 PM

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

#5 gijew

gijew
  • Members
  • PipPipPip
  • Advanced Member
  • 240 posts
  • LocationCalifornia

Posted 12 September 2006 - 07:28 PM

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.
I'm considered good looking in some countries

#6 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 12 September 2006 - 07:29 PM

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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#7 spinFIRE

spinFIRE
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 September 2006 - 07:34 PM

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 http://irodov.nm.ru/wget4web/ - but I want something in php (I can understand that  ;D)
@shocker-z: I will try that tomorrow ;)

-spinFIRE




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users