Upload image form problem
Hej har sidet og arbejdet med bogen byg dit eget cms af heine lennart, og jeg har lavet upload formularen nøjagtig efter bogen og den uploader også til mappen på mit websted men men billed filen ser mærkelig ud i dreamveawer og jeg kan ikke få den til at blive vist på galleri siden.Hvis jeg prøver at skrive billed navnet direkte ned i mysql og ligger billedet over i billed mappen manuelt med php, vises billedet fint.håber i kan hjælpe...
Her er koden for upload form:
<?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 = "../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>
Og her er koden for galleri:
<?php require_once('Connections/cms.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
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 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 do { ?>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="50%"><?php echo '<img height="100" src="billeder/'.$row_rsBilleder['billednavn'].'">'; ?></td>
<td width="50%"><?php echo $row_rsBilleder['billednavn']; ?></td>
</tr>
</table>
<?php } while ($row_rsBilleder = mysql_fetch_assoc($rsBilleder)); ?></body>
</html>
<?php
mysql_free_result($rsBilleder);
?>
