2011-03-12 4 views
1

나는 image upload example from W3Schools으로 놀았지만 업로드 후 나타나는 출력의 글꼴 크기를 변경하고 싶습니다. 나는 id="up_finished"이있는 div 태그 PHP 코드를 주변 노력이 같은 CSS 코드를 만들었 :PHP 에코 출력용 글꼴 크기 변경

#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> 

그러나 아무 일도 일어나지 않았다. 어떻게해야합니까?

+3

그 또는 이와 비슷한 것이 작동해야합니다. 전체 코드를 보여줄 수 있습니까? –

+0

텍스트를 출력하는 PHP 스크립트뿐만 아니라 실제 HTML 페이지로 만드는 데 필요한 다른 태그/코드를 추가 했습니까? doctype 선언, html/body 태그 등) –

+0

id 속성의 unserscrore가 허용되지 않습니다. 브라우저가 CSS 규칙을 무시할 수 있습니까? CSS 규칙이 적용되는 Firebug 또는 Chrome 관리자를 확인하십시오. – konsolenfreddy

답변

1

@Nathan Campos : 다음 코드 샘플도 작동하지 않으면 다른 글꼴 크기가 무시 될 수 있습니다. 다른 스타일 시트 설정 또는 가능한 브라우저 설정.

<!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/