Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $response = "Upload failed";
- if(isset($_POST['usrIMG']) && isset($_POST['usrID']))
- {
- $now = DateTime::createFromFormat('U.u',microtime(true));
- $id = $now->format('YmdHisu');
- $upload_folder = "Uploads";
- $usrID = $_POST['usrID'];
- $usrIMG = $_POST['usrIMG'];
- $path = "$upload_folder/$usrID/$id.jpeg";
- if (!file_exists("$upload_folder/$usrID/"))
- {
- mkdir("$upload_folder/$usrID/", 0777, true);
- }
- $dbhost = 'localhost';
- $dbname = 'dressoff';
- $dbuser = 'root';
- $dbpass = '134679';
- $pdo_info = "mysql:host=$dbhost;dbname=$dbname";
- $conn = new PDO($pdo_info, $dbuser, $dbpass);
- $check = $conn->prepare("INSERT INTO uploads VALUES(?,?)");
- $check->bindParam(1, $_POST['usrID']);
- $check->bindParam(2, $usrID);
- if($check->execute() && file_put_contents($path,base64_decode($usrIMG)) != false)
- {
- $response = "Upload succeed";
- }
- }
- echo $response;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement