:) Ja, man kan desværre aldrig helt undgå små fejl..
Jeg får denne her fejl:
Parse error: syntax error, unexpected T_VARIABLE in /customers/hensel.dk/hensel.dk/httpd.www/upload_ny.php on line 33
Her er mit php doc.:
Jeg har ændret $maxheight til 2000 fordi jeg vil have den skal være proportional i forholdt til width. Kan man ikke lave en if som tager højde for det?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="
http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Upload ny</title>
</head>
<body>
<?php
function resize( $filename, $newfilename, $maxw, $maxh )
{
$srcim = imagecreatefromjpeg( $filename );
$ow = imagesx( $srcim );
$oh = imagesy( $srcim );
$wscale = $maxw / $ow;
$hscale = $maxh / $oh;
$scale = ( $hscale < $wscale ? $hscale : $wscale );
$nw = round( $ow * $scale, 0 );
$nh = round( $oh * $scale, 0 );
$dstim = imagecreatetruecolor( $nw, $nh );
imagecopyresampled( $dstim, $srcim, 0, 0, 0, 0, $nw, $nh, $ow, $oh );
imagejpeg( $dstim, $newfilename, 85 );
imagedestroy( $dstim );
imagedestroy( $srcim );
return file_exists($newfilename);
}
$uploadDir = "/images/blog/"; //Husk mappen skal chmod'es til 644
$maxHeigth = 2000;
$maxWidth = 550;
$maxSize = 4 //Angives i MB
$pics = array('jpeg','jpg','jpe'); //Hvilke filtyper vil vi godtage?
$maxSize = $maxSize * 1024 * 1024;
if($_FILES['userFile']['size'] > 0)
{
$uploadfile = $uploaddir . basename($_FILES['userFile']['name']);
if($_FILES['userFile']['size'] > $maxSize)
{
echo "Dit billede er for stort, prøv med mindre...";
exit();
}
$ext = strtolower(end(explode('.',$_FILES['userFile']['name']);
if(!in_array($ext,$pics))
{
echo "Forkert billede format, prøv med et andet...";
exit();
}
resize( $_FILES['userFile']['tmp_name'], $uploadfile, $maxWidth, $maxHeight );
header("location: " . $_SERVER['PHP_SELF']);
exit();
}
?>
<form enctype="multipart/form-data" action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
<table>
<tr><td>Send this file:</td><td><input name="userFile" type="file" /></td></tr>
<tr><td colspan="2"><input type="submit" value="Send File" /></td></tr>
</table>
</form>
</body>
</html>