<?php
/*
 This function handles the file upload. It will upload the file to the
 directory file_upload and returns the filename. Parameter "uploadedfile"
 need to be passed to make use of this function.  
*/
			if(!isset($target_path)) // If $target_path does not contain any parameter use path by default
			{
			$target_path = "../file_upload/";
			/* Add the original filename to our target path.  
			Result is "uploads/filename.extension" */
			$target_path = $target_path . basename($_FILES['uploadedfile']['name']); 
			} else
			{
			$target_path = $target_path;
			}
			//echo " <br> Target path for file upload. $target_path <br>";
			$_FILES['uploadedfile']['tmp_name'];  
			if(is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) //If file is choosen
			{
					// Check the size of the file 2MB by default it it is set to 3 MB for this script (Which is not safe)
					if($_FILES['uploadedfile']['size'] > 3145728 )
					{
						echo " Your file size is really large";
					}
					if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
 					{
   					echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    				" has been uploaded <br>";
					$filename = basename($_FILES['uploadedfile']['name']);
											// if file is JPG file reduce the file size
								if($_FILES['uploadedfile']['type'] == 'image/jpeg')
								{
									echo "File Source:" . $image_source  = $target_path;
									echo "<br>File Size:". $image_size = 150;
									include("resizeimage.php");
								}
					}
 					else
 					{
    				echo " File can not be uploaded <br>";
					}
			}
	 		else
	  		{
			echo "<br>No attachment selected <br>";
			}
			echo "<br>". $filename . "<br>";
?>		