Skip to content

Instantly share code, notes, and snippets.

@RISHABH3821
Created November 23, 2019 19:09
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 RISHABH3821/1beb88adcbb3420702bfd17b99848a82 to your computer and use it in GitHub Desktop.
Save RISHABH3821/1beb88adcbb3420702bfd17b99848a82 to your computer and use it in GitHub Desktop.
<?php
$target_dir = "uploads/";
$target_file_name = $target_dir . basename($_FILES["file"]["name"]);
$response = array();
if (isset($_FILES["file"]))
{
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file_name))
{
$success = true;
$message = "Uploaded!!!";
}
else
{
$success = false;
$message = "NOT Uploaded!!! _ Error While Uploading";
}
}
else
{
$success = false;
$message = "missing field";
}
$response["success"] = $success;
$response["message"] = $message;
echo json_encode($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment