Hello,
my problem is the following:
I have files in a directory that I wish to download. The links to these files are saved into a database ('Folder/filename.ext' where the folder is just a type to keep the files a bit in order).
So I made a new controller with a downloadAction() where I pick up the file through $_GET['id'] and find the file in the database.
My problem is how to link to this file. Here's my mapstructure:
**NOTE: not all subfolders of application/library have been displayed **
|
|_html
|_images
|_scripts
|_styles
|
|_library
|_UploadFiles
|_Folder (with in these folders the filename.ext)
|
|_application
Scenario:
1) Root dir set to html folder. When I connect to localhost I get redirected to my index.php (bootstrap) in my html folder.
2)In "UploadFiles" there's a folder 'TEXT' and a file called 'test.txt'.
3)Filecontroller has 1 (real) action namely
DownloadAction(). The code to the downloadAction is below.
Code:
$id = $_GET['id'];
$bestand = $this->file->getFile($id);
$this->_redirect($bestand);
$bestand contains the path to the file I want. In this scenario it will return something like this.
Code:
../UploadFiles/TEXT/test.txt
But I keep getting errors saying the file does not exist! I think I can't go higher then my html folder in my controller... is that possible? So how can I reach this file?
All the files have to be downloaded and are in no case supposed to be streamed directly in the page itself.