insert delete image from folder in php with jQuery

Today, We want to share with you insert delete image from folder in php.In this post we will show you jquery multiple image upload with preview and delete demo, hear for Ajax Multiple Image Upload with Edit Delete using PHP Mysql we will give you demo insert image in php and delete image from folder in php example for implement.In this post, we will learn about multiple image upload with preview and delete jquery php with an example.

insert delete image from folder in php

There are the Following The simple About jQuery AJAX Add Delete Multiple Image Upload Full Information With Example and change src of image jquery source code.

Read Also:  jQuery Ajax Upload Multiple Images using PHP

As I will cover this Post with live Working example to develop how to fetch image from database in php using ajax, so the Delete the uploded image file using ajax code for this example is following below light color background images for websites.

Multiple Image Upload using PHP into MYSQL database
Multiple Image Upload using PHP into MYSQL database

Upload and delete image file with jQuery and AJAX

index.php

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(document).ready(function (e) {
	$("#productSubmit").on('submit',(function(e) {
		e.preventDefault();
		$.ajax({
        	url: "upload.php",
			type: "POST",
			data:  new FormData(this),
			contentType: false,
    	    cache: false,
			processData:false,
			success: function(data)
		    {
			$("#previewData").html(data);
		    },
		  	error: function(){} 	        
	   });
	}));	
});
function removeFiles(path) {
	$.ajax({
		url: "delete.php",
		type: "POST",
		data:  {'path':path},
		success: function(data){
			$("#previewData").html('</p>
<p>
</p>
<p>
</p>
<p>
</p>
<div class="no-image">No Image</div>
<p>
</p>
<p>
</p>
<p>
</p>
<p>');
		},
		error: function(){} 	        
	});
}
</script>

<style>
body {<br />font-family: Arial;<br />font-size: 14px;<br />}<br />.bgColor {<br />width: 440px;<br />height:100px;<br />background-color: #c8f5ff;<br />color: #000;<br />padding: 2px;<br />}<br />.bgColor label{<br />font-weight: bold;<br />color: #A0A0A0;<br />}<br />#previewData{<br />float:left;<br />width:100px;<br />height:100px;<br />text-align:center;<br />font-weight: bold;<br />color: #C0C0C0;<br />background-color: #F0E8E0;<br />position:relative;<br />}<br />#productSubmitLayer{<br />float:right;<br />padding: 10px;<br />}<br />.btnSubmit {<br />background-color: #3FA849;<br />padding:4px;<br />border: #3FA849 1px solid;<br />color: #FFFFFF;<br />}<br />.inputFile {<br />padding: 3px;<br />background-color: #FFFFFF;<br />}</p>
<p>.image-container {<br />	display:inline-block;<br />	position:relative;<br />}<br />.image-delete {<br />	position: absolute;<br />    right: 30px;<br />    top: 30px;<br />    border: #FFF 4px solid;<br />    border-radius: 50%;<br />    padding: 7px 10px;<br />    display: none;<br />    cursor: pointer;<br />    opacity: 0.6;<br />    color: #FFF<br />}<br />.no-image {<br />	display: inline-block;<br />    position: absolute;<br />    right: 18px;<br />    top: 40px;<br />}<br /></style>

 
<div class="bgColor"><form id="productSubmit" action="upload.php" method="post">
<div id="previewData">
<div class="no-image">No Image</div>
</div>
<div id="uploadFormLayer"><label>Upload Image File:</label>
<input class="inputFile" name="uploadedFiles" type="file" />
<input class="btnSubmit" type="submit" value="Submit" /></div>
</form></div>

upload.php

<style>
.image-container:hover .image-delete{display:inline-block;}<br /></style>

 
<div class="image-container">

<img src="<?php echo $orignalsetPath; ?>" width="100px" height="100px" />
<div class="image-delete">X</div>
</div>
<!--?php } } } ?-->

delete.php

Read Also:  How to Add Captcha in PHP Registration Form?

delete image from folder in php

<!--?php if(!empty($_POST["path"])) { unlink($_POST["path"]); } ?-->

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jQuery AJAX Add Delete Multiple Image Upload.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  How To Configure Supervisor For Laravel 5/6/7 Queue Jobs?