Page 1 of 1

image uploading, with special parameters.....

Posted: Mon Mar 22, 2004 6:25 pm
by dull1554
here's my image upload script...

iup.php

Code: Select all

<?php
if(!isset($_POST['submit']))
{
Print <<< EOT
<html>
<head>
<title>File uploader</title>
<body>

<form enctype="multipart/form-data" action="uploader.php" method="post">

Choose file upload: <input name="userfile" type="file" /><br />

<input type="submit" value="Upload file" />

</form>
</body>
<html>
EOT;
}
else{
$stripspaces = eregi_replace("_"," ",$_FILES["userfile"]["tmp_name"]);
$ext = substr(strrchr($_FILES['userfile']['name'], '.'), 1);

if ($ext == "gif") {
       copy($_FILES["userfile"]["tmp_name"], "/images/av_con/" . $_FILES["userfile"]["name"]);

      echo "<p>Image uploaded successfully.</p>";

}
else
{
    echo "<p>Please upload GIF image files only!</p>";
}
}
?>
how can i limit the file size to 120kb and also i don't know if i can, but is there a way to limit file demensions....ie. 70px by 70px

just wondering and if there is a way to limit this how might i go about it?
thanks....

Posted: Mon Mar 22, 2004 6:29 pm
by dull1554
or if there is not a way to identify image dimensions with php, how would i do it with JS, id put it in a intermediary step....i guess

Posted: Mon Mar 22, 2004 6:31 pm
by Illusionist
$_FILES['userfile']['size'] will most likely give you the size.

Posted: Mon Mar 22, 2004 6:54 pm
by dull1554
ok so i got the whole file size thing working, but is there a way to control demensions?