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

Link to comment
Share on other sites

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);


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.