PDA

View Full Version : PHP Retrieval!!!!!!!!


gandalfthegrey
05-13-2007, 07:23 PM
I'm going absolutely mad http://www.thestudentroom.co.uk/images/smilies/mad.gif

Does anyone know of a file download script in PHP whch could allow users to start downloading files(text, audio etc). Or possibly a website that could help.

This is the code i'm using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php

global $id;



if(!is_numeric($id))

die("Invalid blobId specified");

// Database connection variables

$dbServer = "host";

$dbDatabase = "DB";

$dbUser = "USER";

$dbPass = "PASS";



$sConn = mysql_connect(lhost, USER, PASS)

or die("Couldn't connect to database server");



$dConn = mysql_select_db($dbDatabase, $sConn)

or die("Couldn't connect to database $dbDatabase");



$dbQuery = "SELECT type, content ";

$dbQuery .= "FROM upload ";

$dbQuery .= "WHERE id = $id";

$result = mysql_query($dbQuery) or die("Couldn't get file list");



if(mysql_num_rows($result) == 1)

{

$fileType = @mysql_result($result, 0, "type");

$fileContent = @mysql_result($result, 0, "content");



header("Content-type: $type");

echo $content;

}

else

{

echo "Record doesn't exist.";

}

?>

</body>
</html>

Thanks in advance

davidj
05-13-2007, 08:26 PM
not sure what you want

you can download files just by linking to them

gandalfthegrey
05-13-2007, 10:20 PM
not sure what you want

you can download files just by linking to them

How can i do this?!? How can i download files from my database?

davidj
05-14-2007, 06:38 AM
you hold the file on the server but hold the path and file name in the database then you just pull that data into an <a tag...

<a href="<?php echo $row['$path']"......