Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['download'])){
- $size=get_size($url);
- $mime = "image\/png"; //for PNG Images
- $name = "phones.png";
- $url = "http://notifisolutions.com/img/backup/phones.png";
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
- {
- header('Content-Type: "' . $mime . '"');
- header('Content-Disposition: attachment; filename="' . $name . '"');
- header('Expires: 0');
- header('Content-Length: '.$size);
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header("Content-Transfer-Encoding: binary");
- header('Pragma: public');
- }
- else
- {
- header('Content-Type: "' . $mime . '"');
- header('Content-Disposition: attachment; filename="' . $name . '"');
- header("Content-Transfer-Encoding: binary");
- header('Expires: 0');
- header('Content-Length: '.$size);
- header('Pragma: no-cache');
- }
- readfile($url);
- }
- function get_size($url) {
- $my_ch = curl_init();
- curl_setopt($my_ch, CURLOPT_URL,$url);
- curl_setopt($my_ch, CURLOPT_HEADER, true);
- curl_setopt($my_ch, CURLOPT_NOBODY, true);
- curl_setopt($my_ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($my_ch, CURLOPT_TIMEOUT, 10);
- $r = curl_exec($my_ch);
- foreach(explode("\n", $r) as $header) {
- if(strpos($header, 'Content-Length:') === 0) {
- return trim(substr($header,16));
- }
- }
- return '';
- }
- ?>
- <html>
- <head><title>Sample Download</title>
- </head>
- <body>
- <h1>Hellcoderz!!</h1>
- <p>This will download file from my other server at <a href="http://notifisolutions.com">notifisolutions.com</a>.<br>
- The file link is <a href="http://notifisolutions.com/img/backup/phones.png">phones.png</a></p>
- <p><a href="?download">Download</a></p>
- </body>
- </html>
Add Comment
Please, Sign In to add comment