karatekid36 Posted May 29, 2007 Share Posted May 29, 2007 In line 25 of this code, it uses header outputs to send the chosen file as a download to the user. I am curious how you would go about changing this code on line 25 so that when the said image is clicked on it is viewed in the browser and not sent as a download prompt. When viewing a page of all the downloads, the filenames are linked so that when you click on them you are sent to this script with a variable. the link is something to this affect www.mysite.com/folder/download_file.php?uid=10. I understand how this code works, I would just like some help to change it from a download prompt to a view file in browser code. Any thoughts? Thank you. <?php // Check for an upload_id. if (isset($_GET['uid'])) { $uid = (int) $_GET['uid']; } else { // Big problem! $uid = 0; } if ($uid > 0) { // Do not proceed! require_once ('./includes/mysql_connect.php'); // Connect to the database. // Get the information for this file. $query = "SELECT file_name, file_type, file_size FROM paddles_class WHERE upload_id=$uid"; $result = mysql_query ($query); list ($fn, $ft, $fs) = mysql_fetch_array ($result, MYSQL_NUM); mysql_close(); // Close the database connection. // Determine the file name on the server. $the_file = './paddles_class/' . $uid; // Check if it exists. if (file_exists ($the_file)) { // Send the file. header ("Content-Type: $ft\n"); header ("Content-disposition: attachment; filename=\"$fn\"\n"); header ("Content-Length: $fs\n"); readfile ($the_file); } else { // File doesn't exist. $page_title = 'File Download'; include ('./includes/header.html'); echo '<p><font color="red">The file could not be located on the server. We apologize for any inconvenience.</font></p>'; include ('./includes/footer.html'); } } else { // No valid upload ID. $page_title = 'File Download'; include ('./includes/header.html'); echo '<p><font color="red">Please select a valid file to download.</font></p>'; include ('./includes/footer.html'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53395-changing-some-header-outputs/ 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.