Cable Forum

Cable Forum (https://www.cableforum.uk/board/index.php)
-   Internet Discussion (https://www.cableforum.uk/board/forumdisplay.php?f=25)
-   -   megaupload.com Question on Effect (https://www.cableforum.uk/board/showthread.php?t=37074)

JediMaster 23-10-2005 12:49

megaupload.com Question on Effect
 
On http://www.megaupload.com they have a Feature I liked, but cant see HOW to do it :confused:

On this URL http://www.megaupload.com/?d=4KP1UGVA you wait 40 seconds then you can SAVE the File. I dont want that part... Next BIT I like.... :p:

1) There is a Button (like a Form Submit one)
2) Click the Button to SAVE File
3) When Pressed a POP-UP "Save Dialouge Box" opens

I dont want a Link & Save As Target, but a Button to LEFT Click & then it opens a Save Box..

Any ideas

LemonyBrainAid 23-10-2005 12:52

Re: megaupload.com Question on Effect
 
Surely the save dialogue box is the same as left clicking it... Just megaupload do it automatically for you...

Personally megaupload gives me too slow speeds :(

Stuart 23-10-2005 13:14

Re: megaupload.com Question on Effect
 
And has FAR to many popups..

Graham M 23-10-2005 13:26

Re: megaupload.com Question on Effect
 
Its probably something to do with the Mime types on the server, theyve probably set it as something that doesnt display directly in your browser for everything and therefor it just straight downloads.

JediMaster 23-10-2005 13:27

Re: megaupload.com Question on Effect
 
If you "Left Click" a Link on a site it OPENS from Location... But on the site I linked has a Download Box & then when you LEFT click it, it opens a Save As box. Not open from Location...

Yeah slow & popups. But the Button I want (not adverts & slow) lol

---------

Is there a Script/Code to use that will re-create this effect without editing MIME types :confused:

punky 23-10-2005 13:43

Re: megaupload.com Question on Effect
 
You would do it like this:


Code:


<script language="javascript">

function savefile() {

window.location="http://ww.site.com/files/file.ext";

}

</script>

<input type="button" value="Download this file..." name="savefile" onclick="savefile()">


JediMaster 23-10-2005 13:52

Re: megaupload.com Question on Effect
 
punky
I was so PLEASED... But it works with .zip (that works with Left Click Link anyway)
I want to save a AVI/MPEG via a Button if you can try a way to do it?

punky 23-10-2005 13:58

Re: megaupload.com Question on Effect
 
Oh right you want to override a MIME type saved in a browser. You can't do that in Javascript, but you apparently can in PHP.

Here's an example.

http://forums.dreamincode.net/showtopic9446.htm

Follow that, and use the code I wrote above to open the .php file you create.

JediMaster 23-10-2005 14:06

Re: megaupload.com Question on Effect
 
Cheers Buddy...

To Re-Cap..

in .htaccess file
Code:

<Files mp3>
ForceType application/x-httpd-php
</Files>

Then... (edit /path/to/mp3/files/ to Folder Path)

Code:

<?php
$uri = explode("/",$_SERVER['PATH_INFO']);
$path = "/path/to/mp3/files/"; //path without any filenames!!! Must have trailing backslash
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($path.$uri[1]));
@readfile($path.$uri[1]);
?>

& add this to the same Page...

Code:

<script language="javascript">
function savefile() {window.location=http://ww.site.com/files/file.ext;}
</script>

<input type="button" value="Download this file..." name="savefile" onclick="savefile()">

Is that correct? :confused:

punky 23-10-2005 14:35

Re: megaupload.com Question on Effect
 
Actually, that example doesn't look totally clear.

Here is a clearer example, from the PHP docs, so its more trustworthy.

PHP Code:

           $filename = 'dummy.zip';
           
$filename = realpath($filename);

           
$file_extension = strtolower(substr(strrchr($filename,"."),1));

           switch (
$file_extension) {
               case 
"pdf": $ctype="application/pdf"; break;
               case 
"exe": $ctype="application/octet-stream"; break;
               case 
"zip": $ctype="application/zip"; break;
               case 
"doc": $ctype="application/msword"; break;
               case 
"xls": $ctype="application/vnd.ms-excel"; break;
               case 
"ppt": $ctype="application/vnd.ms-powerpoint"; break;
               case 
"gif": $ctype="image/gif"; break;
               case 
"png": $ctype="image/png"; break;
               case 
"jpe": case "jpeg":
               case 
"jpg": $ctype="image/jpg"; break;
               default: 
$ctype="application/force-download";
           }

           if (!
file_exists($filename)) {
               die(
"NO FILE HERE");
           }

           
header("Pragma: public");
           
header("Expires: 0");
           
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
           
header("Cache-Control: private",false);
           
header("Content-Type: $ctype");
           
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
           
header("Content-Transfer-Encoding: binary");
           
header("Content-Length: ".@filesize($filename));
           
set_time_limit(0);
           @
readfile("$filename") or die("File not found.") 

save that in a php file. Alter the $filename bit for your file, and then do window.location="http://www.site.com/yournewphpfile.php"


All times are GMT. The time now is 23:16.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum