Here is a pretty basic example...
First make a form to submit the image
<form method=post enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Image: <input type="file" name="img"><br>
<input type="submit" value="Upload">
</form>
and then add this php to it...