<?php
//, restrict your uploads to being images less then 1MB and a jpeg. If an upload does not match the aforementioned criteria, let the user know why the file was unable to be uploaded.
if ($_POST['submit'] == 'Upload'){
if ($_FILES['fileupload']['size'] > 1048576){
    echo 'Your file size is too big';
    exit;   
}
echo $_FILES['fileupload']['type'];
if ($_FILES['fileupload']['type'] !=  'image/jpeg'){
    echo 'We only allow jpegs';
    exit;   
}



foreach ($_FILES['fileupload'] as $key=>$value){
    echo $key.' '.$value.'<br>';
}
echo "Filename is :".$_FILES['fileupload']['name'];

move_uploaded_file($_FILES['fileupload']['tmp_name'],'uploads/'.$_FILES['fileupload']['name']);
}
?>

<form action="uploaddemo.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileupload">
<input type="submit" name="submit" value="Upload">    

</form>      