Hi All,
I am hoping someone can help me. I am very new to PHP and am trying to get mulitple uploads into a database linked to one user name.
I have managed to get this to work but the only problem i have now is i am unable to download both files, it will only download one or the other.
Is there a way i can get files from the form (eventually once this all works it will need to be able to handle max 12 files at once) and compress them into one file then upload them to my database, wheer i can easily download one file.
Below is the code i am using and have been told i cant download both files.
<?
if(isset($_GET['id']))
{
// Details for webhost below:////////////
////////////////////////////////////////
$con = mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("salli_gifts", $con);
$id = $_GET['id'];
$query = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
}
?>
<?
if(isset($_GET['id']))
{
$con = mysql_connect("localhost","*****","*****");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("*****", $con);
$id = $_GET['id'];
$query = "SELECT name2, type2, size2, content2 FROM upload WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name2, $type2, $size2, $content2) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$name2");
header("Content-length: $size2");
header("Content-type: $type2");
}
?>
<html>
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body,td,th {
font-family: BankGothic Lt BT;
font-size: 12px;
}
-->
</style></head>
<body>
<?
// Details for webhost below:////////////
////////////////////////////////////////
$con = mysql_connect("localhost","*****","*****");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("******", $con);
$query = "SELECT COUNT(id) AS numrows FROM upload";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$query = "SELECT id, name, name2 FROM upload";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "<br>";
echo "<br>";
echo "$numrows <b>Download(s)in our database</b>";
echo "<br>";
echo "<br>";
echo "Database is empty <br>";
}
else
{
echo "<br>";
echo "<br>";
echo "$numrows <b>Download(s)in our database</b>";
echo "<br>";
echo "<br>";
while(list($id, $name, $name2) = mysql_fetch_array($result))
{
?>
<a href="download.php?id=<?=$id;?>"><?=$name;?></a> <br>
<a href="download.php?id=<?=$id;?>"><?=$name2;?></a> <br>
<?
}
}
mysql_close($con);
?>
</body>
</html>
Any help wihthis would be appreicated as i am trying to get my wife's webiste up and runnig for her.
Thanks