File "process_upload.php"

Full Path: /home/analogde/www/Freebox/CHESS_ON/process_upload.php
File size: 1.91 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	echo "toto";
	
	if(isset($_FILES["FileInput"]) )
	{
	
	echo "Trace";
	$UploadDirectory	= 'uploads/'; //specify upload directory ends with / (slash)
	
	//check if this is an ajax request
	//if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
	//	die();
	//}
	
	
	//Is file size is less than allowed size.
	if ($_FILES["FileInput"]["size"] > 5242880) 
	{
		die("File size is too big!");
	}
	
	//allowed file type Server side check
	switch(strtolower($_FILES['FileInput']['type']))
		{
			//allowed file types
            case 'image/png': 
			case 'image/gif': 
			case 'image/jpeg': 
			case 'image/pjpeg':
			case 'text/plain':
			case 'text/html': //html file
			case 'application/x-zip-compressed':
			case 'application/pdf':
			case 'application/msword':
			case 'application/vnd.ms-excel':
			case 'video/mp4':
				break;
			default:
				die('Unsupported File!'); //output error
	}
	
	$File_Name          = strtolower($_FILES['FileInput']['name']);
	$File_Ext           = substr($File_Name, strrpos($File_Name, '.')); //get file extention
	$Random_Number      = rand(0, 9999999999); //Random number to be added to name.
	$NewFileName 		= $Random_Number.$File_Ext; //new file name
	
	if(move_uploaded_file($_FILES['FileInput']['tmp_name'], $UploadDirectory.$NewFileName ))
	   {
		die('Success! File Uploaded.');
	}else{
		die('error uploading File!');
	
}
else
{
	die('Something wrong with upload! Is "upload_max_filesize" set correctly?');
}
//http://www.formget.com/ajax-image-upload-php
//http://www.formget.com/upload-multiple-images-using-php-and-jquery/
//http://www.infotuts.com/ajax-multiple-image-upload-javascript-and-php/
//http://blog.teamtreehouse.com/uploading-files-ajax
//http://hayageek.com/docs/jquery-upload-file.php
//http://code.tutsplus.com/tutorials/uploading-files-with-ajax--net-21077
//https://github.com/LPology/Simple-Ajax-Uploader


//http://www.code-hound.com/upload-multiple-files-at-once-with-jquery-and-php/
?>