Skip to content

Instantly share code, notes, and snippets.

@brucenorton
Created November 9, 2018 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brucenorton/a45c482315e90554cd5515449d7c08ae to your computer and use it in GitHub Desktop.
Save brucenorton/a45c482315e90554cd5515449d7c08ae to your computer and use it in GitHub Desktop.
file uploader 2018
<?php
//upload.php
// *** chmod of 'uploads' folder to 777 ***
//create an array for the results
$responseArray = [ "file" => "upload.php" ];
if (isset($_FILES['upload_file'])) {
if(move_uploaded_file($_FILES['upload_file']['tmp_name'], "../deleteMe/" . $_FILES['upload_file']['name'])){
//echo $_FILES['upload_file']['name']. " OK";
$responseArray["response"] = "success";
$responseArray["file"] = $_FILES['upload_file']['name'];
} else {
//echo $_FILES['upload_file']['name']. " KO";
$responseArray["response"] = "fail";
}
echo(json_encode($responseArray));
exit;
} else {
$responseArray["response"] = "fail";
echo(json_encode($responseArray));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment