<?php
	function getExtension($str) {
	$i = strrpos($str,".");
	if (!$i) { return ""; }
		$l = strlen($str) - $i;
		$ext = substr($str,$i+1,$l);
		return $ext;
	}

	$fileID = $_POST['ID'];
	$filename = basename( $_FILES['Filedata']['name']);

	$extension = getExtension($filename);
	$extension = strtolower($extension);
	$uploadID = $fileID.'.'.$extension;
	if (move_uploaded_file($_FILES['Filedata']['tmp_name'], "blog_images/".$uploadID))
	{
		 echo "OK";
	}
	else
	{
		 echo "ERROR";
	}
?>