Page 1 of 1

What is the download call

PostPosted: Sat May 19, 2012 11:30 pm
by asktod
What is the code that calls the file to be downloaded like the one once you press download. Trying to add media embedding

Re: What is the download call

PostPosted: Sun May 20, 2012 1:16 am
by SamEA
What exactly are you trying to accomplish?

Re: What is the download call

PostPosted: Sun May 20, 2012 1:48 am
by asktod
SamEA wrote:What exactly are you trying to accomplish?

Playing media. Do you know what the file download code is?

this is what I have
Code: Select all
<?php echo $scripturl. "download.php?a=" . $filecrc . "&b=" . md5($foundfile[2].$_SERVER['REMOTE_ADDR']) ?>

Re: What is the download call

PostPosted: Tue May 22, 2012 12:08 pm
by SamEA
File Download code? Do you mean the direct link to the uploaded file? ./download2.php is where a download link is generated, which enables the user to download a file. If you are trying to implement a video player or similar, you'll have to customise download2.php's HTML Headers' MEME type to application/x-shockwave-flash (for SWF) for example.

Re: What is the download call

PostPosted: Wed May 23, 2012 12:47 am
by asktod
This have something to do with it?
"
$validdownload = 0;


$filecrc = $_GET['a'];
$filecrctxt = $filecrc.".dfh";
if (file_exists("./files/".$filecrctxt)) {
$fh = fopen ("./files/".$filecrctxt,r);
$thisline= explode('|', fgets($fh));
if ($thisline[0]==$_GET['a'] && md5($thisline[2].$_SERVER['REMOTE_ADDR'])==$_GET['b'])
$validdownload=$thisline;
fclose($fh);"

Re: What is the download call

PostPosted: Sat May 26, 2012 1:06 am
by SamEA
Nope, this part in ./download2.php:
Code: Select all
header('Content-type: application/octetstream');
header('Content-Length: ' . filesize("./storage/".$validdownload[0]));
header('Content-Disposition: attachment; filename="'.$validdownload[1].'"');
readfile("./storage/".$validdownload[0]);


Basically, I'd recommend the user to click on "Download Now" (in which you can modify the template e.g. DL Now to "Play Now" button), where afterwards a generated ID for download2.php is generated, and a video player can be implemented and links to the generated ID e.g. download2.php?a=839Video.mp4&b=75e216be623ac45ffbc88f8332da9060 which should play the requested video.

Nevertheless, I am unsure whether or not you'll have to change the Content-type from application/octetstream to the appropriate content type.