Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-05-2008, 08:40 AM
Junior Member
 
Join Date: Apr 2008
Posts: 18
Default Downloading a file through browser

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-05-2008, 10:56 AM
Junior Member
 
Join Date: Apr 2008
Posts: 18
Default

I think I fixed it so far. Haven't tried with compressed files (ZIP, etc..) or executables (exe, msi, ...) yet
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-05-2008, 11:46 AM
Junior Member
 
Join Date: Apr 2008
Posts: 18
Default

Okay.... PDF / TXT / XLS work. So I reckon most files are allowed to be downloaded.

I'm just puzzled why any .exe / .msi executable file is being marked as "invalid" and ignored?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:21 AM.