更改 PHP Echo 输出的字体大小
我一直在玩 W3Schools 的图像上传示例,但我想更改上传后显示的输出的字体大小。我尝试使用具有 id="up_finished"
的 div
标签包围 php 代码,并制作如下 CSS 代码:
#up_finished {
font-size: 10px;
}
我的代码是这样的:
<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>
但什么也没有发生了。我应该怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Nathan Campos:如果以下代码示例也不起作用,则其他内容可能会覆盖您的字体大小;另一个样式表设置或者很可能是浏览器设置。
jsFiddle: http://jsfiddle.net/phF9b/ 查看正在运行的代码。
@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.
jsFiddle: http://jsfiddle.net/phF9b/ to see the code in action.