Тема: Як за допомогою ajax вставити картинку в бд
form enctype="multipart/form-data">
<input type="file" name="myimage" id="myimage" onchange="preview_image(event)">
<input type="submit" name="submit_image" id="submit" value="Upload">
<img id="output_image"/>
</form>
</div>
<script>
$("#submit").click(function() {
var myimage = $("#myimage").val();
$.ajax ({
url: 'getdata.php',
type: 'POST',
dataType: 'json',
data: {'myimage': myimage},
});
});
</script>
<?php
$con = mysqli_connect("localhost","root","","root");
?>
<?php
$myimage = $_GET['myimage'];
$imagename = $_FILES["myimage"]["name"];
$imagetmp= addslashes(file_get_contents($_FILES['imagename']['tmp_name']));
$stmt = mysqli_query($con,"INSERT INTO tbl_images(`name`) VALUES('$imagename')");
?>