Force file download

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Post by Oleg Butuzov » Sun Nov 24, 2002 3:47 am

http://php.spb.ru

Code: Select all

<?
     
     $so = fsockopen("php.spb.ru", 80, &$errno, &$errstr, 30);
     fputs($so,"GET /files/notepad.exe HTTP/1.0\nHOST: php.spb.ru\n\n");

     while(fgets($so,2048)!="\r\n" && !feof($so));
   
     unset($buf);
     while(!feof($so)) $buf.=fread($so,2048);
 
      fclose($so);
      echo "Download fine, size ".strlen($buf)." bytes."; flush();

     $f=fopen("download.tmp","wb+");
     fwrite($f,$buf,strlen($buf));
     fclose($f);
   
?>

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests