由于某种原因,我的800x800px图像被修剪了。但是,当我使用80x80px时,它似乎没有被修剪。我该如何解决?它还说我在SQL中有一个斑点-64kib。如何增加限额?仅显示图像的20%。解决了,我用blob代替了mediumblob。它不是重复的,因为与What is the maximum length of data I can put in a BLOB column in MySQL?的问题不同,但是它们都有相同的解决方案。
if(isset($_POST["insert"]))
{
$file = addslashes(file_get_contents($_FILES["image"]["tmp_name"]));
$query = "UPDATE users SET image='$file' WHERE email= '$param_email'";
if(mysqli_query($connect, $query))
{
echo '<script>alert("Image Inserted into Database")</script>';
}
}
?>
Html:
<form method="post" enctype="multipart/form-data">
<input type="file" src=
<?php
$query = "SELECT image FROM users where email='$param_email'";
$result = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($result))
{echo'"data:image/jpeg;base64,'.base64_encode($row['image'] ).'"';}?> name="image" id="image" />
<input type="submit" name="insert" id="insert" value="Insert" class="btn btn-info" />
</form>
<table>
<?php
$query = "SELECT image FROM users where email='$param_email'";
$result = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($result))
{
echo '
<tr>
<td>
<img src="data:image/jpeg;base64,'.base64_encode($row['image'] ).'" height="200" width="200" class="img-thumnail" />
</td>
</tr>
';
}
?>
</table>
JS:
<script>
$(document).ready(function(){
$('#insert').click(function(){
var image_name = $('#image').val();
if(image_name == '')
{
alert("Please Select Image");
return false;
}
else
{
var extension = $('#image').val().split('.').pop().toLowerCase();
if(jQuery.inArray(extension, ['gif','png','jpg','jpeg']) == -1)
{
alert('Invalid Image File');
$('#image').val('');
return false;
}
}
});
});
</script>
谢谢大家!请也分享此内容,以便可以更快地解决它:)