PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Mar 22, 2004 6:25 pm
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....
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Mar 22, 2004 6:29 pm
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
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Mon Mar 22, 2004 6:31 pm
$_FILES['userfile']['size'] will most likely give you the size.
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Mar 22, 2004 6:54 pm
ok so i got the whole file size thing working, but is there a way to control demensions?