Hi,
I am hoping someone can help me.. I am trying to set out and ordering system for my wife's business.
At this stage I have a basic form that can upload multiple files to a sql database. Which i have working (not as i think it should, but working).
I have 2 things i want it to do:
- Form be abe to upload as many files as 12 but still upload if only 2 images are selected.
- Bea ble to rettrieve the files from the database easily in one go. At the moment to code below will allow me to view both file names on screen but only download 1 of them.
I am open to a better idea or someone pointing me in the direction of how to fix this or be able to compress all the uploaded files in to 1 zip folder and put that file in the databse instead of all the separate files.
I hope this is making sense, it is very late and i have been trying to get this to work for hrs.
<?
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","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("salli_gifts", $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","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("salli_gifts", $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>
Your help is much apprecited. I hope this post is formatted properly this time.
Thanks.!!!