•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,708 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,446 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 882 | Replies: 6
![]() |
•
•
Join Date: Jul 2006
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
I have a folder called _secure in which I have a .htaccess file that denies all access to the _secure folder. Within the _secure folder I also have a swf file. I'm using PHP to retrieve the secured swf file and show it if the user is logged in. For some reason my code bellow doen't seem to work. I would appreciate any help.
$filename = $_GET['filename'];
$dir = '_secure/';
if ( user_logged_in() ) {
download_file( $filename, $dir );
} else {
header("HTTP/1.1 404 Not Found"); // dead end
}
function download_file( $fname, $path) {
$fpath = $path.$fname; // absolute path to file
$fsize = filesize( $fpath ); // size of file
header('Content-Type: application/x-shockwave-flash');
$content = file_get_contents($fpath);
echo $content;
}
$filename = $_GET['filename'];
$dir = '_secure/';
if ( user_logged_in() ) {
download_file( $filename, $dir );
} else {
header("HTTP/1.1 404 Not Found"); // dead end
}
function download_file( $fname, $path) {
$fpath = $path.$fname; // absolute path to file
$fsize = filesize( $fpath ); // size of file
header('Content-Type: application/x-shockwave-flash');
$content = file_get_contents($fpath);
echo $content;
}
any erros outputted?
If you are dnying all access to the "secure" are there any entries in the apache error logs?
I would wrap the file_get_contents() call in an if statement, this way you can see where the program fails. maybe try echoing the path fname, fpath variables out, see what they are set to.
Also add these to the top of your file
[PHP]
error_reporting(E_ALL);
display_errors(1);
[/PHP]
If you are dnying all access to the "secure" are there any entries in the apache error logs?
I would wrap the file_get_contents() call in an if statement, this way you can see where the program fails. maybe try echoing the path fname, fpath variables out, see what they are set to.
Also add these to the top of your file
[PHP]
error_reporting(E_ALL);
display_errors(1);
[/PHP]
•
•
Join Date: Jul 2006
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
I got it to work. But since it is a swf 5mb file it takes a while to get it. How can I fix this?
•
•
•
•
any erros outputted?
If you are dnying all access to the "secure" are there any entries in the apache error logs?
I would wrap the file_get_contents() call in an if statement, this way you can see where the program fails. maybe try echoing the path fname, fpath variables out, see what they are set to.
Also add these to the top of your file
[php]
error_reporting(E_ALL);
display_errors(1);
[/php]
•
•
Join Date: Mar 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
You can try to increase the maximum execution time via set_time_limit() function or via php.ini if it is disabled (it is 30 seconds by default).
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- writing to a file (Java)
- can't find file size over 3 megabytes to clean up harddrive (Windows NT / 2000 / XP / 2003)
Other Threads in the PHP Forum
- Previous Thread: Dynamic array with update
- Next Thread: New to php and need some help with a guestbook


Linear Mode