rendered paste body<?php
function imagesize($image) {
list($width, $height, $type, $attr) = getimagesize($image);
$imagetype = array( 1 => "GIF", 2 => "JPG",
3 => "PNG", 4 => "SWF",
5 => "PSD", 6 => "BMP",
7 => "TIFF", 8 => "TIFF",
9 => "JPC", 10 => "JP2",
11 => "JPX", 12 => "JB2",
13 => "SWC", 14 => "IFF",
15 => "WBMP", 16 => "XBM"
);
$image = array("width" => $width, "height" => $height, "type" => $imagetype[$type], "attr" => $attr);
return $image;
}
if($_POST['submit']){
$uploaddir = "D:\\www\\www\\jpgsc\\files\\";
$sizeallowed = 1048576;
$tempname = $_FILES['userfile']['tmp_name'];
$filename = $_FILES['userfile']['name'];
$size = $_FILES['userfile']['size'];
$imagesize = imagesize($tempname);
$filetype = $imagesize[2];
if ($filetype == 'JPG' || $filetype == 'GIF') {
if ($tempname != ''){
if ($size > $sizeallowed) {
echo 'The file you uploaded is bigger than 1MB';
} else {
move_uploaded_file($tempname, $uploaddir . $filename);
echo '<a href="http://localhost/jpgsc/files/'.$filename.'">Click here</a> to see it.';
}
}
} else {
echo 'The file you uploaded is not the correct type';
}
echo "<br /><br />";
print_r($_FILES);
echo '<br />';
print_r($imagesize);
} else { ?>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<font face="Courier New" size="2">
Filetypes allowed: JPG<br />
Max File Size: 1MB<br /><br />
</font>
<form enctype="multipart/form-data" action="" method="POST">
<input name="userfile" type="file"><br />
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
<?php
}
?>