buddyram Posted September 19, 2012 Share Posted September 19, 2012 <?php $fname = $_GET['q']; mysql_connect('localhost', 'root', ''); mysql_select_db('db_name'); $q = mysql_query("SELECT * from files where file_name = '$fname' "); if(mysql_num_rows($q) == 1) { while($row = mysql_fetch_array($q)) { $contents = stripslashes($row['file_content']); header("Content-length: {$row['file_size']}"); header("Content-type: {$row['file_type']}"); header("Content-Disposition: attachment; filename=$fname"); echo $contents; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/268538-file-is-downloading-but-the-contents-are-displayed/ Share on other sites More sharing options...
Mahngiel Posted September 19, 2012 Share Posted September 19, 2012 pretty code. you do that? Quote Link to comment https://forums.phpfreaks.com/topic/268538-file-is-downloading-but-the-contents-are-displayed/#findComment-1379178 Share on other sites More sharing options...
Christian F. Posted September 19, 2012 Share Posted September 19, 2012 Article. Quote Link to comment https://forums.phpfreaks.com/topic/268538-file-is-downloading-but-the-contents-are-displayed/#findComment-1379196 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.