文字和图片评论表

时间:2017-06-13 21:33:36

标签: php html

我是编程新手。我为此做了研究答案,但无法解决问题。我希望我的网站成员能够发布评论(进入聊天),可以选择文本和/或图片上传。文本部分工作正常,但我没有显示图片。

<?php
if(isset($_POST['submit']))
{
$name = $_FILES['file']['comment2'];
$temp = $_FILES['file']['tmp_name'];
move_uploaded_file($temp,"uploadedpics/".$name);
echo $handle;
echo '<img src="uploadedpics/".$name />';
}
?>

<?php
date_default_timezone_set("America/New_York");

if($_POST){
$content = test_input($_POST["comment"]);
$content2 = test_input($_POST["comment2"]);
$handle = fopen("comments.html","a");
fwrite($handle,"<b>" . $profile_username . "</b>:<br/>" . $content . "<br/>" 
. $content2 . "<br/>" . date("h:i:a m-d-Y") . "<br/>" );
fclose($handle);
echo '<img src="uploadedpics/".$name />';
}

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
?>

<h2>let's chat, fellow remix galleryers!</h2>
<p><span class="error">* required field.</span></p>
<form action="my-profile.php" method="post" enctype="multipart/form-data"> 
<fieldset>
<div class='container'>
 Comment: <textarea name="comment" rows="5" cols="30"><?php echo $handle;?>
          </textarea>
</div>           
<div class='container'>
 Photo: <input type="file" name="comment2" id="file" accept="image/*"/>

</div>
<div class='container'>
       <input type="submit" name="submit" value="Submit"/>
</div>
</fieldset>
</form>
<?php include "comments.html"; ?>

0 个答案:

没有答案