Smells alot like homework, but I'll get you in the right direction.
you need to have a multipart/form-data form
You will also need to know what your max height, and your max width shoudl be.
Then take a look at
www.php.net/imagecopyresized or
www.php.net/imagecopyresampledThese things might look a little confusing at first, but you're going to need to do some research on what it is you need.
Start by figuring out what the layout is..
basically, if width > height, the layout is landscape, and the other way around is rather obvious.
Then figure what you want the maximum size you want the picture to be, both in height and width.
then compare the size of the picture to the size that you consider max, and then divide max_w into the size of the picture to get the aspect ratio that you want.
ie..
$size = getimagesize($file); //www.php.net/getimagesize
This creates an array of width,height,mimetype and a few other things.. very useful.
so, in english (not code since I believe this to be homework) ..
if layout is landscape
then width = size[width] / max_w
else it will be height = size[height] / max_h
This will give you an aspect ratio..
Then you will divide the other dimensions accordingly
Then you'll create a blank image using
www.php.net/createimagetruecolor with the new height and dimensions (this creates a picture resource)
Then you'll use imagecopyresized or imagecopyresampled to copy the original picture, albet resized into the new resource.
Then depending on whatever mimetype it was, ie.. png,gif,jpg|jpeg you'll use
imagejpeg() [or so on] to create and write the file to disk.
then, if you want the user to be able to see the picture they just uploaded..
create an HTML reference like this..
<img src="directory/picture.jpg?<?=date('U')?>" border="0">
(applying the unix datestamp will ensure that the browser reloads the picture every time)
There are tons of references on the net for doing this very thing, and if it is homework, I hope you don't pladgerize, because otherwise you won't learn anything.