Welcome Guest, Not a member yet? Register   Sign In
File name
#1

[eluser]Unknown[/eluser]
Hi I am trying to get the file name from the URL to pass it to force_download() function how do i do that?

Here is how the url looks base_url('downloads/file1.mp3'). When i click on the file name i get 404 page not found. I have the download.php which includes the following code:
Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Downloads extends CI_Controller
{
    public function index()
    {
        
    $this->load->helper('download');
    $data = file_get_contents('./application/views/uploads/file1.mp3');
    $name = 'file1.mp3';
    force_download($name, $data);
        
        
    }
}

Now instead of file1.mp3 in the file_get_contents('./application/views/uploads/file1.mp3') i want to store the name portion in a variable $fileName and then pass it to file_get_contents.

Thanks in advance.




Theme © iAndrew 2016 - Forum software by © MyBB