papaface Posted December 8, 2006 Share Posted December 8, 2006 Hello,I was wondering if someone could help me.Currently I have the following code:download.php[code]<?phprequire("connect.php");require("dbselect.php");$id = $_GET['id'];$selectfrmdb = "select name,type,size,upload "."from uploads where upID = '$id'";$result = mysql_query($selectfrmdb,$con)or die('Error, query failed');list($name,$type,$size,$upload) = mysql_fetch_array($result);header("Content-length: $size");header("Content-type: $type");header("Content-Disposition: attachment; filename=$name");echo $upload;mysql_close($con);exit;?>[/code]When I go to download.php?id=1 i get prompted to save a file called download.php instead of the filename or file that I want to download from the database.If you need anymore information in order to help me with this let me know.Thanks Quote Link to comment Share on other sites More sharing options...
mdub2112 Posted December 8, 2006 Share Posted December 8, 2006 I'm basically having the same problemhttp://www.phpfreaks.com/forums/index.php/topic,117889.0.htmlHowever, maybe yours will work better, try thishttp://www.phpfreaks.com/forums/index.php/topic,95433.0.html Quote Link to comment Share on other sites More sharing options...
gijew Posted December 8, 2006 Share Posted December 8, 2006 Well a couple of things come to mind here.1. Is PHP installed correctly? I'm sure it is but, well, it happens. Can you view any other PHP enabled pages?2. WOrking on a download script I had this happen once as well. It ended up being due to a bad path. From what you posted there it looks as if you're trying to download from the same directory as the file. Try throwing a few conditionals in there to help diagnose the issue...if (!file_exists($file)) { echo 'not found';} else { //download} Quote Link to comment Share on other sites More sharing options...
papaface Posted December 8, 2006 Author Share Posted December 8, 2006 Im trying to download from the database, not a directory.Also php is installed fine. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted December 8, 2006 Share Posted December 8, 2006 One thing I've noticed is that if a script gets executing for a very long time, well not sure how long but.. anyway it prompts me to download the script and not the information I wanted.Perhaps the file that you're pulling from the database is too large for your php.ini files to handle in script execution time? Quote Link to comment Share on other sites More sharing options...
papaface Posted December 8, 2006 Author Share Posted December 8, 2006 Nope. The file is 66kb. It is an image file. The browser doesnt hang. It just sends me download.php instead of the file i want. Quote Link to comment Share on other sites More sharing options...
papaface Posted December 8, 2006 Author Share Posted December 8, 2006 Hello,I have managed to do this. Thanks for your pointers :D Quote Link to comment 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.