uploader.bind('FilesAdded',files) {
/
@@ Show / hide various elements /
$('.upload-message').hide();
$('.info-message').hide();
$('#upload_button').show();
$('#filelist_header').show();
/
@@ This is the file upload class which does all the uploading work. /
include('class.upload.php');
if(isset($_FILES["file"])) {
/
@@ Generating unique name for the photo. /
$time = time();
$rand_1 = rand(999,999999);
$rand_2 = rand(999999,999999999);
$rand_3 = rand();
$uniquevalue = $time.''.$rand1.''.$rand2.''.$rand_3;
/
@@ Folder creation for each and every day. This ensures performance even with millions of images. /
$folder = date('zY');
if(substr($folder,0) == 0) {
$folder = '367'.date('Y');
}
/
@@ This folder is for the source image files. /
$pfolder = '../upload/source/';
if(!is_dir($pfolder)) {
mkdir($pfolder,0755);
}
/
@@ This folder is for the image files with 120x120 dimensions. /
$tfolder = '../upload/small/';
if(!is_dir($tfolder)) {
mkdir($tfolder,0755);
}
/
@@ Assigning the upload file to the upload class for all the processing. /
$handle = new Upload($_FILES["file"]);
if($handle->uploaded) {
$extension = $handle->file_src_name_ext;
$mime = $handle->file_src_mime;
if(($mime == 'image/gif') || ($mime == 'image/jpg') || ($mime == 'image/png') || ($mime == 'image/bmp') || ($mime == 'image/pjpeg') | ($mime == 'image/jpeg')) {
/
@@ Check if the uploaded filetype is an image or not. /
if(($extension == 'gif') || ($extension == 'jpg') || ($extension == 'jpeg') || ($extension == 'png') || ($extension == 'bmp') || ($extension == 'pjpeg')) {
if($handle->image_src_x > 500) {
/
@@ Check if the filesize is smaller than 10 MB. 10 MB = 10485760 bytes. /
if($handle->file_src_size < 10485760) {
/
@@ Getting the actual file name (with and without extension) and sanitizing it for inserting in the database. /
$real_name = clean_input($handle->file_src_name);
$body_name = clean_input($handle->file_src_name_body);