如何将css类应用于上传的图像


How to apply css class to uploaded image?

假设我有一个类标签工作正常的代码:

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

它显示正确,但没有应用类,当我尝试下面的代码时,它显示错误。有什么解决方案吗?请帮忙。所以我可以为每个上传的图像应用类代码,同时在浏览器中显示文件。

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

而不是

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

尝试

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

有打字错误

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