I went to give the unique name to picture and I save 2 picture and every picture name will be unique.
this code work correct but give the related name and one problem more when i refresh page picture upload again.
$video_type = trim($_GET['video_type']);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$target_dir = "pictures/";
$name1 = $_FILES["img_url1"]["name"];
$name2 = $_FILES["img_url2"]["name"];
$target_file = $target_dir . basename($_FILES["img_url1"]["name"]);
$target_filez = $target_dir . basename($_FILES["img_url2"]["name"]);
$videoFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if (strtolower(end(explode(".",$name))) =="jpg") {
$uploadOk = 1;
} elseif(strtolower(end(explode(".",$name))) =="png" ) {
$uploadOk = 1;
}else {
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
$_SESSION['error'] = "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["img_url"]["tmp_name"], $target_file) && move_uploaded_file($_FILES["img_urlz"]["tmp_name"], $target_filez)) {
$sql = "INSERT INTO picture (pic1, pic2, approved)
VALUES ('$name1', '$name2' , 'false')";
if ($db->query($sql) === TRUE) {
$_SESSION['success'] = 'picture uploaded successfully.';
} else {
$_SESSION['error'] = $sql . "<br>" . $db->error;
}
} else {
$_SESSION['error'] = "Sorry, there was an error uploading your file.";
}
}
}