【发布时间】:2011-03-13 06:26:10
【问题描述】:
我一直在玩image upload example from 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>
但是什么也没发生。我该怎么办?
【问题讨论】:
-
那个或类似的东西应该可以工作。你能显示完整的代码吗?
-
您是否添加了使其成为实际 HTML 页面而不仅仅是输出文本的 PHP 脚本所需的其他标签/代码? (诸如 doctype 声明、html/body 标签等)
-
不允许在 id 属性中使用 unsercrore,也许您的浏览器忽略了 CSS 规则?检查应用了哪些 CSS 规则的 Firebug 或 Chrome 检查器
-
@freddy K.:那篇文章写于 2001 年,当时 CSS2 还没有得到广泛支持。除非您仍然支持 Netscape 浏览器或 IE5,否则它不再适用。