You need enctype="multipart/form-data" within your form tag, and a hidden input of MAX_FILE_SIZE set to a large number. so your form would look like:
<form method="post" action="upload2.php" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
Upload picture: <input name="img1" type="file">
<input type="submit" name="upload" value="Upload file">
</form>
Also, use the move_uploaded_file() function:
if (move_uploaded_file($_FILES["img1"]["tmp_name"], "/var/www/html/testimages/" . $random_number . ".jpeg")) {
} else {
$log .= "Couldn't copy image to server<br>";
}
You need to use the temporary filename for the file that has been uploaded, and not the filename it was originally called. The file gets uploaded to a temporary area first, so PHP needs to know what the temporary filename is to move it.