Nathan Campos
Nathan Campos

Reputation: 29507

Change Font Size For PHP Echo Output

I have been playing around with the image upload example from W3Schools, but I want to change the font size of the output that appears after the upload. I've tried surrounding the php code with a div tag that has the id="up_finished" and made a CSS code like this:

#up_finished {
    font-size: 10px;
}

My code is like this:

<form>
    <center>
        <div id="upfinished">
            <?php
                $img_org_name = $_FILES["file"]["name"];
                $img_ext = "." . pathinfo($img_org_name, PATHINFO_EXTENSION);
                $img_name = generateKey() . $img_ext;
                $img_type = $_FILES["file"]["type"];
                $img_error = $_FILES["file"]["error"];
                $img_size = $_FILES["file"]["size"];
                $img_tmp = $_FILES["file"]["tmp_name"];

                if ((($img_type == "image/gif")
                    || ($img_type == "image/png")
                    || ($img_type == "image/jpeg")
                    || ($img_type == "image/tiff")
                    || ($img_type == "image/bmp")
                    || ($img_type == "image/pjpeg"))
                    && ($img_size < 4194304))
                {
                    if ($img_error > 0)
                    {
                        echo "Error: " . $img_error . "<br />";
                    } else {
                        echo "Upload: " . $img_name . "<br />";
                        // echo "Type: " . $img_type . "<br />";
                        echo "Size: " . round(($img_size / 1048576), 2) . " Mb<br />";

                        if (file_exists("img/" . $img_name))
                        {
                            echo $img_name . " already exists. ";
                        } else {
                            move_uploaded_file($img_tmp, "img/" . $img_name);
                            echo "Stored in: " . "img/" . $img_name;
                        }
                    }
                } else {
                    echo "Error! Try re-submiting the image <br />
                         Error ID: " . $img_error . "<br />";
                }

                function generateKey()
                {
                    $chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
                    srand((double)microtime()*1000000); 
                    $i = 0; 
                    $pass = '' ; 

                    while ($i <= 3)
                    { 
                        $num = rand() % 33; 
                        $tmp = substr($chars, $num, 1); 
                        $pass = $pass . $tmp; 
                        $i++; 
                    } 
                    return $pass;
                }
            ?>
        </div>
    </center>
</form>

But nothing happened. What should I do?

Upvotes: 1

Views: 8267

Answers (1)

stealthyninja
stealthyninja

Reputation: 10371

@Nathan Campos: If the following code sample also doesn't work, something else might be overriding your font size; either another stylesheet setting or quite possible, a browser setting.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>questions/5285643</title>

<style type="text/css">
<!--
#up_finished {
    font-size: 10px;
}
#up_finished span {
    /* for demonstration purposes */
    font-size: 16px;
}
// -->
</style>
</head>

<body>

<form>
    <center>
        <div id="up_finished">
            <?php
            /* Replace this with your PHP code */
            ?>
            <br />Filler text which should be
            10px large<br />
            <span>Filler text which should be
            16px large</span>
        </div>
    </center>
</form>

</body>
</html>

jsFiddle: http://jsfiddle.net/phF9b/ to see the code in action.

Upvotes: 1

Related Questions