2014-09-21 19 views
0

說我有代碼級的標籤做工精細:如何將CSS類應用於上傳的圖像?

<img src="img/group2.jpg" class="findface" /> 

現在,當我通過給定的代碼上傳文件並顯示它:

<?php 
$target_path = "./"; 
$target_path = $target_path . basename($_FILES['uploadedfile']['name']); 
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)){ 
echo'<img src="'.$target_path.'" />'; 
} 
?>  
<body> 
<form enctype="multipart/form-data" action="<?php $_PHP_SELF ?>" method="POST"> 
<input type="hidden" name="file" value="upload file" /> 
Choose a file to upload: <input name="uploadedfile" type="file" /><br /> 
<input type="submit" value="Upload File" /> 
</form> 
</body> 

這是正常顯示,但不應用類,當我嘗試下面的代碼顯示errors.Any解決方案?請help.So我可以應用上傳的每個圖像的類代碼以及在瀏覽器中顯示文件。

echo'<img src="'.$target_path.'" /> class="findface"; 
+0

爲什麼收盤外面的課嗎? /> class =「findface」你的意思是class =「findface」/> – 2014-09-21 15:15:10

回答

1

代替

echo'<img src="'.$target_path.'" /> class="findface"; 

嘗試

echo "<img src='".$target_path."' class='findface' />"; 
+0

哦天才,thanx很多工作。我已經嘗試了近10個小時來自己做,但不成功。我該怎麼做這個愚蠢的錯誤?無論如何, thanx。 – 2014-09-21 08:40:37

0

有錯字

echo '<img src="'.$target_path.'" class="findface">'; 
+0

是的,thanx它也工作。 – 2014-09-21 08:41:02