uploadimage.php 954 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. session_start();
  3. $http_host = $_SERVER["HTTP_HOST"];
  4. $doc_root = $_SERVER["DOCUMENT_ROOT"] . "/";
  5. include $doc_root . "functions.php";
  6. $proto = get_protocol();
  7. $lang = "en";
  8. $con = start_db();
  9. $server = $proto . $http_host;
  10. $pserver = $proto . substr($http_host, 0, strpos($http_host, ':')); // public server
  11. if (!check_session($con)){
  12. http_response_code(401);
  13. header("Location: /authentication.php");
  14. }
  15. else{
  16. foreach ($_POST as $key => $value){
  17. error_log("{$key} = {$value}");
  18. }
  19. $name = mysqli_real_escape_string($con, $_GET["name"]);
  20. $base64string = $_POST["image"];
  21. error_log("FILENAME: $name");
  22. error_log("PATH: $doc_root../www/img/blog/DEBUG_$name");
  23. error_log("B64: $base64string");
  24. file_put_contents("$doc_root../www/img/blog/DEBUG_$name", base64_decode($base64string));
  25. echo("OK");
  26. }
  27. ?>