这是我如何将图像插入数据库以及如何显示它,所有这些代码都在同一页面上 如果有人知道我的图像在显示时会旋转的原因,请告诉我。 任何形式的帮助将不胜感激:)
<form enctype="multipart/form-data" onsubmit="return validate()" name="registration" method="post" >
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" >User Image: <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" name="userImage" type="file" />
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="reset" class="btn btn-primary">Clear</button>
<button id="send" type="submit" name="subtn" class="btn btn-success">Submit</button>
</div>
</div>
</form>
if(count($_FILES) > 0)
{
if(is_uploaded_file($_FILES['userImage']['tmp_name']))
{
if(isset($_POST["subtn"]))
{
$imgData =addslashes(file_get_contents($_FILES['userImage']['tmp_name']));
$imageProperties = getimageSize($_FILES['userImage']['tmp_name']);
$sqlregister = "insert into users (imageType ,imageData)
values ('{$imageProperties['mime']}', '{$imgData}')
";
<div class="profile_pic">
<a href="editProfile.php" data-toggle="modal" data-target="#myModal" >
<?php
echo '<img src="data:image/jpeg;base64,'.base64_encode( $img ).'" height="50" width="70" class="img-circle profile_img" />';
?>
</a>
</div>