Created
April 29, 2020 10:30
-
-
Save prensmiskin/f4080144809206cdf4c49a80bce1b0bc to your computer and use it in GitHub Desktop.
SAhnarts APP Kullanıcıların sunucuya video yükle işlemini yerine getiren web servis.
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 | |
if($_SERVER['REQUEST_METHOD']=='POST'){ | |
$dosyaUzantisi = substr($_FILES["image"]["name"],-4,4); | |
$dosyaAdi = rand(1,99999).$dosyaUzantisi; | |
$mailx = $_POST["mailx"]; | |
$dosyaYolu = "imga/".$dosyaAdi; | |
$servername = "delete"; | |
$username = "delete"; | |
$password = "delete"; | |
$dbname = "delete"; | |
try { | |
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); | |
// set the PDO error mode to exception | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$v = $conn->prepare("select * from register where mail='$mailx' AND imagename=? "); | |
$v->execute(array('1')); | |
$x = $v->fetch(PDO::FETCH_ASSOC); | |
$d = $v->rowCount(); | |
if($d){ | |
$result["success"] = 4; | |
echo json_encode($result); | |
if(is_uploaded_file($_FILES["image"]["tmp_name"])){ | |
$tasi = move_uploaded_file($_FILES["image"]["tmp_name"],$dosyaYolu); | |
} | |
$sql = "UPDATE register SET imagename='$dosyaAdi ' WHERE mail='$mailx' "; | |
// Prepare statement | |
$stmt = $conn->prepare($sql); | |
// execute the query | |
$stmt->execute(); | |
if($stmt){ | |
$result["success"] = 1; | |
echo json_encode($result); | |
}else{ | |
$result["success"] = 2; | |
echo json_encode($result); | |
} | |
}else{ | |
$result["success"] = 22; | |
echo json_encode($result); | |
//$dirs = scandir($dosya); | |
/* $sql = "INSERT INTO testred (code ) | |
VALUES ('$ee')" ; | |
// use exec() because no results are returned | |
$conn->exec($sql); | |
*/ | |
} | |
} | |
catch(PDOException $e) | |
{ | |
echo $sql . "<br>" . $e->getMessage(); | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment