Welcome Guest, Not a member yet? Register   Sign In
Uploading / Secure Download + Steaming!
#1

[eluser]shenanigans01[/eluser]
Hello, I'm working on a project where a user will upload a .mp3 file. Once the file is uploaded it will be renamed, and the name will be saved in a database. I have the following code for downloading the file which I found here on the forums: which will have the .mp3 files stores outside of the htdocs folder on the server to prevent people from accessing the file as it needs to be secure. My question is the following: Is there anyway to have the .mp3 file outside of the webroot, but still able to stream it to a flash .mp3 player? Is there anything in CI currently that could be used to accomplish that. Any idea's anyone has would be amazing. The goal is to offer a download that will have an expiring link once someone purchases the .mp3 file... but we want to allow the user to hear it before hand. If anyone has a better solution on how to get this up and going I'm all ears and hear to learn. thanks.

-Mike

Code:
// (...) do something to authenticate visitor

// Fetch download filename from database
$filename = $this->downloads->fetch((int) $this->uri->segment(3))
$file = '../downloads/' . filename ;

// Read file contents and force download
if (file_exists($file) && is_file($file)) {
    $this->load->helper('download');
    $data = file_get_contents($file);
    force_download($filename, $data);
}
else {
    show_error('Sorry, this file does not seem to exist');
}


Messages In This Thread
Uploading / Secure Download + Steaming! - by El Forum - 05-28-2009, 04:22 PM
Uploading / Secure Download + Steaming! - by El Forum - 05-28-2009, 05:39 PM
Uploading / Secure Download + Steaming! - by El Forum - 05-28-2009, 05:56 PM
Uploading / Secure Download + Steaming! - by El Forum - 05-28-2009, 05:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB