Created
May 29, 2016 12:14
-
-
Save TimDorand/ea8332567be35e6231aa8bf50ae84e65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type : bitmap; charset=utf-8'); | |
if(isset($_POST["encoded_string"])){ | |
$encoded_string = $_POST["encoded_string"]; | |
$image_name = $_POST["image_name"]; | |
$decoded_string = base64_decode($encoded_string); | |
$path = 'images/'.$image_name; | |
$file = fopen($path, 'wb'); | |
$is_written = fwrite($file, $decoded_string); | |
fclose($file); | |
if($is_written > 0) { | |
$connection = mysqli_connect('timotheefxtim.mysql.db','timotheefxtim','Adminparis96','timotheefxtim'); | |
// $connection = mysqli_connect('localhost', 'root', '','tutorial3'); | |
$query = "INSERT INTO photos(name,path) values('$image_name','$path');"; | |
$result = mysqli_query($connection, $query) ; | |
if($result){ | |
echo "success"; | |
}else{ | |
echo "failed"; | |
} | |
mysqli_close($connection); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment