I can't see your flowchart very well, but here is a basic explanation of uploading. Feel free to ask any other questions towards the subject.
You're going to need to first work on security. Uploading is a very very dangerous thing if exploited (they can access all of your files). Look into the $_FILES superglobal. You can use this to determine various things such as: File size, File extension, and the name, etc. This is also required for uploading.
The absolute first thing you want to do before working on your actual goal, is check for security. First set a standard on what file extensions you want to be allowed. Use something like:
<?php
$extensions = array("jpg", "jpeg", "png", "gif");
$extension = end(explode(".", $_FILES['upload']['name']));
if(!in_array($extension, $extensions)) {
die("Extension not allowed");
}
?>
Now, you're of course going to want to check for more things, but you must make sure they can only upload what you allow them to at the very least.
If you want to convert a file to use a specific extension, use
imagejpeg() or
imagepng() or
imagegif()
Once you have finished security, processing, and converting, you next want to upload your image. To do this, use
move_uploaded_file(). Note, that if the image already exists, it will be overwritten. That is why you want to rename your images as well. Here is what I would use to rename an image:
<?php
// Get the extension
$file_ext = end(explode(".", $_FILES['upload']['name']));
// Get the temporary image file, received upon submission
$tmp = $_FILES['upload']['tmp_name'];
// The upload path
$target = "uploads/";
// Here is where you rename the file
$new_file = uniqid() . ".$file_ext";
// Create your new target. uploads/(uniqid output).(file extension)
$target = $target.$new_file;
// Move the uploaded file to the target
move_uploaded_file($tmp, $target);
?>