Hello all,
After playing around with the options, I've found that the following method
for uploading something with constraints is the easiest...
The sample below first checks for 3 constraints (jpg, size, and width) and
if it is cool it uploads it but renames it first...
--------------------------------------
<form name="form1" method="post" action="" enctype="multipart/form-data">
<?php
$dir = "images/";
$maxfilesize = 90000;
$maxwidth = 640;
$uniq = uniqid("");
$extension = ".jpg";
$filename = $_FILES['imagefile']['tmp_name'];
$newfilename = $dir.$uniq.$extension;
$filesize = filesize($filename);
$size = getimagesize($filename);
$width = $size[0];
if(isset( $Submit ))
{
if ($_FILES['imagefile']['type'] != "image/pjpeg")
{
print("File must be a .jpg. File will not be accepted; please choose a
.jpg picture or convert the picture to .jpg format.");
unlink($filename); // This will remove the temporary file
}
if($filesize > $maxfilesize)
{
print("Max filesize of $maxfilesize breeched. File will not be
accepted; please choose a smaller picture or crop this picture.");
unlink($filename);
}
if($width > $maxwidth)
{
print("Max width of $maxwidth breeched. File will not be accepted.");
unlink($filename);
}
move_uploaded_file($filename, $newfilename);
}
?>
<input type="file" name="imagefile" size="20">
<p>
<input type="submit" name="Submit" value="Submit">
</form>
-----------------------------------------------
thanks to all those on this board who helped and to
http://www.experts-exchange.com/Web/Web_Languages/PHP/PHP_Databases/Q_20745560.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php