devWhiz Posted June 4, 2012 Share Posted June 4, 2012 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 https://forums.phpfreaks.com/topic/263614-how-would-i-go-about-having-php-download-a-file-that-is-prompted-in-browser/ Share on other sites More sharing options...
devWhiz Posted June 4, 2012 Author Share Posted June 4, 2012 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 https://forums.phpfreaks.com/topic/263614-how-would-i-go-about-having-php-download-a-file-that-is-prompted-in-browser/#findComment-1351022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.