This document describes how to use PHP to block the upload of adult or nude images to a website. It includes code for an image filtering class that analyzes uploaded images and calculates a "skin pixel score" to detect nudity. The code provides a file upload form built with jQuery, PHP to process the uploads, and integrates the image filtering class to block inappropriate images from being saved. Database tables are also included to store user profiles and uploaded images.
This document describes how to use PHP to block the upload of adult or nude images to a website. It includes code for an image filtering class that analyzes uploaded images and calculates a "skin pixel score" to detect nudity. The code provides a file upload form built with jQuery, PHP to process the uploads, and integrates the image filtering class to block inappropriate images from being saved. Database tables are also included to store user profiles and uploaded images.
This document describes how to use PHP to block the upload of adult or nude images to a website. It includes code for an image filtering class that analyzes uploaded images and calculates a "skin pixel score" to detect nudity. The code provides a file upload form built with jQuery, PHP to process the uploads, and integrates the image filtering class to block inappropriate images from being saved. Database tables are also included to store user profiles and uploaded images.
Images using PHP. FORM IMAGE PHP UPLOAD WEB DEVELOPMENT { 10 comments } inShare I found an interesting and useful class file in phpclasses.org, that helps to detect image nudity based on skin pixel score developed by Bakr Alsharif from Egypt. I had integrated this with my previous tutorial Ajax image upload with Jquery and PHP, sure this code helps you to block adult or nudity images.
Download Script Live Demo
Sample database design for Users.
Users Contains user details username, password and email etc. CREATE TABLE `users` ( `uid` int(11) AUTO_INCREMENT PRIMARY KEY, `username` varchar(255) UNIQUE KEY, `password` varchar(100), `email` varchar(255) UNIQUE KEY )
Javascript Code $("#photoimg").live('change',function(){})- photoimg is the ID name of INPUT FILE tag and $('#imageform').ajaxForm() - imageform is the ID name of FORM. While changing INPUT it calls FORM submit without refreshing page using ajaxForm() method. Uploaded images will <i>prepend</i> inside <i>#preview</i> tag. <script type="text/javascript" src="http://ajax.googleapis.com/ ajax/libs/jquery/1.8.1/jquery.min.js"></script> <script type="text/javascript" src="jquery.wallform.js"></script> <script type="text/javascript"> $(document).ready(function() {
$('#photoimg').live('change', function() { var A=$("#imageloadstatus"); var B=$("#imageloadbutton");
}); </script> Here hiding and showing #imageloadstatus and #imageloadbutton based on form upload submit status.
index.php Contains simple PHP and HTML code. Here $session_id=1 means user id session value. <?php include('db.php'); session_start(); $session_id='1'; // User login session value ?> <div id='preview'> </div> <form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'> Upload image: <div id='imageloadstatus' style='display:none'><img src="loader.gif" alt="Uploading...."/></div> <div id='imageloadbutton'> <input type="file" name="photoimg" id="photoimg" />
</div> </form>
ajaximage.php Contains PHP code. This script helps you to upload images into uploads folder. Image file name rename into timestamp+session_id.extention <?php include('db.php'); session_start(); $session_id='1'; // User session id $path = "uploads/";