php изменить размер изображения или до загрузки

Как мне изменить размер изображения до или во время загрузки?

    
     prepare($sql) or die("failed!");
                                $q->bindParam(':price', $price, PDO::PARAM_STR);
                                $q->bindParam(':contact', $contact, PDO::PARAM_STR);
                                $q->bindParam(':category', $category, PDO::PARAM_STR);
                                $q->bindParam(':user_id', $user_id, PDO::PARAM_STR);
                                $q->bindParam(':fname', $fname, PDO::PARAM_STR);
                                $q->bindParam(':lname', $lname, PDO::PARAM_STR);
                                $q->bindParam(':imagename', $imagename, PDO::PARAM_STR);
                                $q->bindParam(':conditional', $conditional, PDO::PARAM_STR);
                                $q->execute();


    $sql1 = "UPDATE people SET firstname = (SELECT firstname FROM user WHERE username=:user_id1) WHERE username=:user_id2";
                                $q = $conn->prepare($sql1) or die("failed!");
                                $q->bindParam(':user_id1', $user_id, PDO::PARAM_STR);
                                $q->bindParam(':user_id2', $user_id, PDO::PARAM_STR);
                                $q->execute();


    $sql2 = "UPDATE people SET surname = (SELECT surname FROM user WHERE username=:user_id1) WHERE username=:user_id2";
                                $q = $conn->prepare($sql2) or die("failed!");
                                $q->bindParam(':user_id1', $user_id, PDO::PARAM_STR);
                                $q->bindParam(':user_id2', $user_id, PDO::PARAM_STR);
                                $q->execute();


    header("Location: success.php");
    exit;
}
else
{
    // A common cause of file moving failures is because of bad permissions on the directory attempting to be written to
    // Make sure you chmod the directory to be writeable
    $_SESSION['error'] = "Could not upload file.  Check read/write permissions on the directory";
    header("Location: securedpage1.php");
    exit;
}
?>

Ответы на вопрос(2)

Ваш ответ на вопрос