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 Link to comment https://forums.phpfreaks.com/topic/29970-download-file-from-mysql-database/ 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 Link to comment https://forums.phpfreaks.com/topic/29970-download-file-from-mysql-database/#findComment-137681 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} Link to comment https://forums.phpfreaks.com/topic/29970-download-file-from-mysql-database/#findComment-137700 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. Link to comment https://forums.phpfreaks.com/topic/29970-download-file-from-mysql-database/#findComment-137702 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? Link to comment https://forums.phpfreaks.com/topic/29970-download-file-from-mysql-database/#findComment-137712 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. Link to comment https://forums.phpfreaks.com/topic/29970-download-file-from-mysql-database/#findComment-137718 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 Link to comment https://forums.phpfreaks.com/topic/29970-download-file-from-mysql-database/#findComment-137752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.