Jump to content

How would I go about having PHP download a file that is prompted in browser?


devWhiz

Recommended Posts

Say I a URL that automatically prompts you to download a file as soon as the page loads, what code can I use to be able to use PHP to download the file that is prompted from the URL?

 

For example; when you visit http://windows.php.net/downloads/releases/php-5.3.13-nts-Win32-VC9-x86.msi it automatically prompts you to download the PHP installation file, how can I use a PHP script to save the instillation to my computer automatically?

 

Thanks!

 

-CLUEL3SS

Well I just wrote this function and it worked.. I see what I was doing wrong now..

 

$handle = fopen("http://windows.php.net/downloads/releases/php-5.3.13-nts-Win32-VC9-x86.msi", "r");
$newfile = fopen("php.msi", "w");

while(!feof($handle)){
	$read = fread($handle, 1024*;
	$write = fwrite($newfile, $read);
}
fclose();
echo "Done\n";
sleep(20000);


Archived

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

×
×
  • Create New...

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.