<?php
if(isset($_POST['submit']))
{
    $temp_name = $_FILES["file"]["tmp_name"]; // get the temporary filename/path on the server
    $name = $_FILES["file"]["name"]; // get the filename of the actual file
  
    // print the array (for reference)
    print_r($_FILES);
          
    // Create uploads folder if it doesn't exist.
    if (!file_exists("public")) {
        mkdir("public", 0775);
        chmod("public", 0775); // Set read and write permissions of folder, needed on some servers
    }
          
    // Move file from temp to uploads folder
    //$newfilename = time() . '_' . rand(100, 999) . '.' . end(explode(".",$_FILES["image_file"]["name"]));
    //move_uploaded_file($_FILES["image_file"]["tmp_name"], "public/" . $newfilename);
    move_uploaded_file($temp_name, "public/$name");
    chmod("public/$name", 0775); // Set read and write permissions if file
  
}
?> 
      
<title>I.C.A.R.U.S. Imeji Uploader</title>
<p>I.C.A.R.U.S. Imeji Uploader</p>
<form action="" method="post" enctype="multipart/form-data">
    <input type="file" name="file" id="file" />
    <input type="submit" name="submit" value="submit"/>
</form>