Semas Posted December 19, 2008 Share Posted December 19, 2008 Hello everyone, i have some problems using readfile(); it worked before i reinstalled windows and now... it doesn't. Here is the code: <?php include("config.php"); //there is connection to mysql server and so on... $query = mysql_query("SELECT * FROM files WHERE file_code=\"{$_GET['file']}\""); //selects a file from mysql server with hash that is in url $result = mysql_fetch_array($query); //puts everything in array /* im not sure but i think there is one more problem with headers */ if($result['file_type'] == "Image"){ $header = "Content-type: image/jpg"; $dir = "images"; $dl_header = "Content-Disposition: attachment; filename=\"$site_linkimages/{$result['file_name_full']}\""; }else if($result['file_type'] == "Flash"){ $header = "Content-type: application/x-shockwave-flash"; $dir = "flash"; $dl_header = "Content-Disposition: attachment; filename=\"$site_linkflash/{$result['file_name_full']}\""; }else if($result['file_type'] == "Games"){ $header = "Content-type: application/x-shockwave-flash"; $dir = "games"; $dl_header = "Content-Disposition: attachment; filename=\"$site_linkgames/{$result['file_name_full']}\""; }else if($result['file_type'] == "Music"){ $header = "Content-type: audio/mpeg"; $dir = "music"; $dl_header = "Content-Disposition: attachment; filename=\"$site_linkmusic/{$result['file_name_full']}\""; } if($_GET['type'] == "download"){ if(mysql_num_rows($query) > 0){ /* i can download the file */ header($header); header($dl_header); header("Content-Type: application/download"); header("Content-Length: ".filesize("$dir/{$result['file_name_full']}")); readfile("$dir/{$result['file_name_full']}"); } }else if($_GET['type'] == ""){ if(mysql_num_rows($query) > 0){ /* download works but readinng and displayng in site dosent work, i have no idea why. */ header($header); readfile("$dir/{$result['file_name_full']}"); }else { header("Location: $site_link"); } } ?> P.S. When i open files directly trough browser i can see them, but when using files.php and this code it does not work P.SS. If I'm doing something wrong, tell me. examples: http://78.63.197.71/?page=Files&type=Image&file=525bceda113719785656d3b3b238336b http://78.63.197.71/images/funny-hellos-172.jpg Quote Link to comment https://forums.phpfreaks.com/topic/137675-problems-with-reading-file/ Share on other sites More sharing options...
Semas Posted December 19, 2008 Author Share Posted December 19, 2008 If anyone has any ideas tell me. Quote Link to comment https://forums.phpfreaks.com/topic/137675-problems-with-reading-file/#findComment-719526 Share on other sites More sharing options...
JonnoTheDev Posted December 19, 2008 Share Posted December 19, 2008 Are the paths correct? Have you echoed out the filepath to check? readfile("$dir/{$result['file_name_full']}"); Have the files got read permissions? What is the error you are receiving? Quote Link to comment https://forums.phpfreaks.com/topic/137675-problems-with-reading-file/#findComment-719726 Share on other sites More sharing options...
Semas Posted December 19, 2008 Author Share Posted December 19, 2008 Are the paths correct? Have you echoed out the filepath to check? readfile("$dir/{$result['file_name_full']}"); Have the files got read permissions? What is the error you are receiving? Filepaths are ok. But im not sure about the permisions... And there is no errors. Quote Link to comment https://forums.phpfreaks.com/topic/137675-problems-with-reading-file/#findComment-719734 Share on other sites More sharing options...
Semas Posted December 19, 2008 Author Share Posted December 19, 2008 Ok... found prblem... with new php is different coding, i didnt knew it. Still found what problem i had. Quote Link to comment https://forums.phpfreaks.com/topic/137675-problems-with-reading-file/#findComment-719760 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.