Lid |
|
Ik ben bezig met o.a. foto's bestanden uploaden. Maar hoe dan ook werkt het nogal niet.
<!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>
<style>
input {
background-color: #fff;
border: 1px solid #ddd;
font: 11px, verdana;
}
</style>
</head>
<body>
<?php
error_reporting(E_ALL);
if(IsSet($_POST['submit'])) {
if(!empty($_FILES['foto']['name'])) {
$file[0] = end(explode('.', $_FILES['foto']));
$file[1] = $_FILES['foto']['size'];
$file[2] = time() . microtime();
if($file[0] != 'jpg' OR $file[0] != 'jpeg' OR $file[0] != 'gif' OR $file[0] != 'png') {
echo 'Geen geldige extensie, probeer opnieuw!';
} elseif($file[1] >= (250*1024)) {
echo 'Het foto bestand is '.($file[2] * 1024).' KB, en het maximale grootte is '.(250*1024).' KB.';
} else {
if(file_exists($file[2])) {
echo 'Het bestand bestaat inmiddels al.';
} else {
copy($_FILES['foto']['tmp_name'], $file[2]);
echo 'Succesvol upgeload met de naam, '.$file[2].'.';
}
}
} else {
echo 'Geen foto bestand gekozen.';
}
} else {
?>
<form method="post" name="form">
<input type="file" name="foto" /><br />
<input type="submit" name="submit" value="Upload godverdomme!" />
</form>
<?php
}
?>
</body>
</html>
<!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> <style> input { background-color: #fff; border: 1px solid #ddd; font: 11px, verdana; } </style> </head> <body> <?php if(IsSet($_POST['submit'])) { if(!empty($_FILES['foto']['name'])) { $file[1] = $_FILES['foto']['size']; if($file[0] != 'jpg' OR $file[0] != 'jpeg' OR $file[0] != 'gif' OR $file[0] != 'png') { echo 'Geen geldige extensie, probeer opnieuw!'; } elseif($file[1] >= (250*1024)) { echo 'Het foto bestand is '.($file[2] * 1024).' KB, en het maximale grootte is '.(250*1024).' KB.'; } else { echo 'Het bestand bestaat inmiddels al.'; } else { copy($_FILES['foto']['tmp_name'], $file[2]); echo 'Succesvol upgeload met de naam, '.$file[2].'.'; } } } else { echo 'Geen foto bestand gekozen.'; } } else { ?> <form method="post" name="form"> <input type="file" name="foto" /><br /> <input type="submit" name="submit" value="Upload godverdomme!" /> </form> <?php } ?> </body> </html>
|