<?php

/*

UploadiFive

Copyright (c) 2012 Reactive Apps, Ronnie Garcia

*/



// Set the uplaod directory

$uploadDir = '../../../files/programacion/';



// Set the allowed file extensions

$fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // Allowed file extensions



$verifyToken = md5('unique_salt' . $_POST['timestamp']);



if (!empty($_FILES) && $_POST['token'] == $verifyToken) {

	$tempFile   = $_FILES['Filedata']['tmp_name'];

	//$uploadDir  = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;

	$targetFile = $uploadDir . $_FILES['Filedata']['name'];



	// Validate the filetype

	$fileParts = pathinfo($_FILES['Filedata']['name']);

	if (in_array(strtolower($fileParts['extension']), $fileTypes)) {



		//crear carpeta si no existe

		mkdir(str_replace('//','/',$uploadDir), 0755, true);

		// Save the file

		move_uploaded_file($tempFile, $targetFile);

		echo 1;



	} else {



		// The file type wasn't allowed

		echo 'Invalid file type.';



	}

}

?>