Skip to content

Instantly share code, notes, and snippets.

@arn-ob
Created October 16, 2018 13:25
Show Gist options
  • Select an option

  • Save arn-ob/802c483bf74441ad725e0350013f9614 to your computer and use it in GitHub Desktop.

Select an option

Save arn-ob/802c483bf74441ad725e0350013f9614 to your computer and use it in GitHub Desktop.
File upload like Firebase. Store to the online Host file Dir
<?php
$target_dir = "uploads/";
$filename = $_POST["filename"];
$target_file = $target_dir . $filename;
if (file_exists($_FILES["fileToUpload"]["tmp_name"])) {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo json_encode(array("message" => "Upload Success.!"));
} else {
echo json_encode(array("message" => "Upload Failed.!"));
}
} else {
echo json_encode(array("message" => "No Files Found.!"));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment