Visning af billeder
Jeg har et lille CMS site hvor alt indholdet ligger i en MySql database. Med en upload funktion kan man ligger billeder op også.Desværre er der noget der ikke er lavet helt korrekt da jeg ikke kan få billederne vist efter de er uploadet, men der vises blot et rødt kryds.
Se evt. en af siderne her:
http://www.toftebaekhus.dk/test/index.php?id=14&mainid=2
Håber der er nogen der kan hjælpe.
Her er koden for upload.php, til upload af billeder:
-----------------------------------------------------------------
<?php require_once('../Connections/cms.php');
mysql_select_db($database_cms, $cms);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload billede</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if (isset($_FILES['filnavn'])) {
print "Fil, der er blevet overført: {$_FILES['filnavn']['name']}<p>\n";
$query = "INSERT INTO billeder SET billednavn='".$_FILES['filnavn']['name']."'";
$Result1 = mysql_query($query, $cms) or die(mysql_error());
}
{
$tempfile = $_FILES['filnavn']['tmp_name'];
$destination = "/test/billeder/{$_FILES['filnavn']['name']} ";
copy($tempfile, $destination);
}
?>
<form action="upload.php" method="post" enctype="multipart/form-data" name="form1">
<p>Fil, der skal overføres:
<input name="filnavn" type="file" id="filnavn">
</p>
<p>
<input type="submit" name="Submit" value="Overfør">
</p>
</form>
</body>
</html>
-----------------------------------------------------------------
Her er koden for gallery.php
-----------------------------------------------------------------
<?php require_once('../Connections/cms.php'); ?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
mysql_select_db($database_cms, $cms);
$query_rsBilleder = "SELECT * FROM billeder";
$rsBilleder = mysql_query($query_rsBilleder, $cms) or die(mysql_error());
$row_rsBilleder = mysql_fetch_assoc($rsBilleder);
$totalRows_rsBilleder = mysql_num_rows($rsBilleder);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Billedgalleri</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<?php do { ?>
<tr>
<td width="50%"><?php echo '<img height="100" src="/test/billeder/'.$row_rsBilleder['billednavn'].'">'; ?></td>
<td width="50%"><?php echo $row_rsBilleder['billednavn']; ?></td>
</tr>
<tr>
<td colspan="2"><hr size="1" noshade></td>
</tr>
<?php } while ($row_rsBilleder = mysql_fetch_assoc($rsBilleder)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($rsBilleder);
?>
-----------------------------------------------------------------