Am using HTML to upload images and process form in PHP in my form i need the following
<input type="file" id="files" name="files[]" multiple/>
<script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
if (window.File && window.FileList && window.FileReader) {
$("#files").on("change", function(e) {
var files = e.target.files,
filesLength = files.length;
for (var i = 0; i < filesLength; i++) {
var f = files[i]
var fileReader = new FileReader();
fileReader.onload = (function(e) {
var file = e.target;
$("<img></img>", {
class: "imageThumb",
src: e.target.result,
title: file.name
}).insertAfter("#files");
});
fileReader.readAsDataURL(f);
}
});
} else {
alert("Your browser doesn't support to File API")
}
});
</script>
$file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
$file1 = filter_input(INPUT_POST, 'file1', FILTER_SANITIZE_STRING);
$file2 = filter_input(INPUT_POST, 'file2', FILTER_SANITIZE_STRING);
$file3 = filter_input(INPUT_POST, 'file3', FILTER_SANITIZE_STRING);
$file4 = filter_input(INPUT_POST, 'file4', FILTER_SANITIZE_STRING);
withe the above code i need to store image name to SQL database
I would suggest that you take a look here :
how can I upload multiple files at a single browse using jquery or JavaScript
and here :
Count and limit the number of files uploaded (HTML file input)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With