Skip to content

Instantly share code, notes, and snippets.

@prensmiskin
Created April 29, 2020 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prensmiskin/f4080144809206cdf4c49a80bce1b0bc to your computer and use it in GitHub Desktop.
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.
<?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