Har en billed upload form, skal bruge en lister..
Hejsa, jeg står og mangler en lister der gør flg.3 billeder 100*100 thumbs (bare nedskaleret) pr række
5 rækker pr side
Auto side skift, med nyeste billeder på side 1
Mine koder ser således ud:
Formlen:
<html>
<head>
<title>Upload brugerbillede</title>
</head>
<body>
<p align="center">
<b><font size="2" face="Verdana">Upload et billede</font></b><br><br>
</p>
<form method="post" enctype="multipart/form-data" action="uploadfunction.php">
<center>
<table border="0" width="40%" id="table1" cellspacing="4" cellpadding="0">
<tr>
<td width="133"><font size="1" face="Verdana">Billedekategori:</font></td>
<td>
<select size="1" name="category" style="border: 1px solid #000000; padding: 0">
<option selected>Vælg en kategori</option>
<option value="1">Sjove billeder</option>
<option value="2">Wallpapers</option>
<option value="3">Owned</option>
<option value="4">De søde små dyr</option>
</select></td>
</tr>
<tr>
<td width="133"><font face="Verdana" size="1">Vælg billede:</font></td>
<td>
<input type="file" name="userfile" size="17" style="border: 1px solid #000000; padding: 0"></td>
</tr>
</table>
</center>
<p align="center"><font face="Verdana" size="1">OBS: Tryk kun "Fyr den op!" én
gang.</font><br>
<input type="submit" value="Fyr det op!" style="border: 1px solid #000000; padding: 0">
</p>
</form>
</body>
</html>
Uploaderen/uploadfunction.php
<link href="stylesheet/styles.css" rel="stylesheet" type="text/css">
<body bgcolor="#B2C7D9">
<?
// Upload egenskaber
//$folder = "upload/kat1/"; // Mapper vi smider filerne i
if ($_POST['category'] == 1) { $folder = "billeder/sjove/"; }
elseif ($_POST['category'] == 2) { $folder = "billeder/wallpapers/"; }
elseif ($_POST['category'] == 3) { $folder = "billeder/owned/"; }
elseif ($_POST['category'] == 4) { $folder = "billeder/dyr/"; }
$maxlimit = 2457600; // Set maximum file limit (in bits) - 300kb
$allowed_ext = "jpg,gif,png,jpeg"; // Set allowed extensions (split using comma)
$overwrite = "no"; // Allow file overwrite? yes/no
$match = ""; // Clear match variable; for security purposes
$filesize = $_FILES['userfile']['size']; // Get file size (in bits)
$filename = strtolower($_FILES['userfile']['name']); // Get file name; make it all lowercase
if(!$filename || $filename==""){ // File not selected
$error = "- Du har ikke valgt et billede til upload.<br>";
}elseif(file_exists($folder.$filename) && $overwrite=="no"){ // Check if file exists
$error = "- Filen: $filename eksiterer allerede - omdøb venligst og prøv igen.<br>";
}
// Check if file size
if($filesize < 1){ // File is empty
$error .= "- File size is empty.<br>";
}elseif($filesize > $maxlimit){ // File is more than maximum
$error .= "- Filen er for stor - maksimale tilladte str. er 300kb.<br>";
}
$file_ext = preg_split("/\./",$filename); // Split filename at period (name.ext)
$allowed_ext = preg_split("/\,/",$allowed_ext); // Create array of extensions
foreach($allowed_ext as $ext){
if($ext==$file_ext[1]) $match = "1"; // File is allowed
}
// File extension not allowed
if(!$match){
$error .= "- Filtypen er ikke tilladt: $filename<br>";
}
if($error){
print "Fejl under upload af billedet:<br> $error"; // Display error messages
}else{
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $folder.$filename)){ // Upload file
print "Billedet: $filename er nu uploadet.";
}else{
print "Error! File size might exceed upload limit of server. Try again."; // Display error
}
}
?>