PHP expert |
|
heb ergens dit upload script van geplukt alleen hij maakt alle images in mijn members map aan terwijl het in de submap images van members moet :-)
iemand die zo aardig is om mij te helpen
<html>
<head>
</head>
<body>
<center>
<form enctype="multipart/form-data" action="upload.php" method="POST">
Send this file: <input name="file" type="file" /><br />
<input type="submit" name="upload" value="Upload File" />
</form>
</center>
</body>
</html>
<center>
<?php
if(isset($_POST['upload'])) {
function generate_rand($l){
$c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
for($i=0; $i<$l; $i++)
{
$rand.= $c[rand()%strlen($c)];
}
return $rand;
}
$uploaddir = "./";
$maxfilesize = 1048576;
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$filetmpname = $_FILES['file']['tmp_name'];
$valid = array (".jpg",".gif",".png");
$max_width = 300;
$max_height = 300;
if ($filename) {
$error = "";
if ($filesize == 0) {
$error .= "The submitted file was invalid.<br />";
}
$type = strtolower(strstr($filename, '.'));
if (!in_array($type, $valid)) {
$error .= "The submitted file was of invalid type.<br />";
}
if ($filesize>$maxfilesize) {
$error .= "The submitted file was larger than a Megabyte.<br />";
}
list($width, $height, $t, $w) = getimagesize($filetmpname);
if ($width > $max_width|$height > $max_height) {
$error .= "The image dimensions are larger than the maximum dimensions(".$max_width."x".$max_height.")";
}
$randnum = generate_rand(10);
$randnum .= $type;
$file_exists = true;
while ($file_exists) {
if (file_exists("$uploaddir$randnum")) {
$randnum = generate_rand(10);
$randnum .= $type;
}else{
$file_exists = false;
}
}
if ($error == "") {
if (move_uploaded_file($filetmpname, "$uploaddir$randnum")) {
chmod("$uploaddir$randnum", 0644);
echo "Your file was successfully uploaded!<br />";
echo "<a href='.$uploaddir$randnum.'>Click here to go to your upload!</a>";
} else {
echo "Your file could not be uploaded.";
}
}else{
echo $error;
}
}else{
echo "No file was uploaded";
}
}
?>
</center>
<html> <head> </head> <body> <center> <form enctype="multipart/form-data" action="upload.php" method="POST"> Send this file: <input name="file" type="file" /><br /> <input type="submit" name="upload" value="Upload File" /> </form> </center> </body> </html> <center> <?php if(isset($_POST['upload'])) { function generate_rand($l){ $c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for($i=0; $i<$l; $i++) { } return $rand; } $uploaddir = "./"; $maxfilesize = 1048576; $filename = $_FILES['file']['name']; $filesize = $_FILES['file']['size']; $filetmpname = $_FILES['file']['tmp_name']; $valid = array (".jpg",".gif",".png"); $max_width = 300; $max_height = 300; if ($filename) { $error = ""; if ($filesize == 0) { $error .= "The submitted file was invalid.<br />"; } $error .= "The submitted file was of invalid type.<br />"; } if ($filesize>$maxfilesize) { $error .= "The submitted file was larger than a Megabyte.<br />"; } if ($width > $max_width|$height > $max_height) { $error .= "The image dimensions are larger than the maximum dimensions(".$max_width."x".$max_height.")"; } $randnum = generate_rand(10); $randnum .= $type; $file_exists = true; while ($file_exists) { $randnum = generate_rand(10); $randnum .= $type; }else{ $file_exists = false; } } if ($error == "") { chmod("$uploaddir$randnum", 0644); echo "Your file was successfully uploaded!<br />"; echo "<a href='.$uploaddir$randnum.'>Click here to go to your upload!</a>"; } else { echo "Your file could not be uploaded."; } }else{ } }else{ echo "No file was uploaded"; } } ?> </center>
|