-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuploadcover.php
42 lines (30 loc) · 1.1 KB
/
uploadcover.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
session_start();
// Create connection
$conn = new mysqli("localhost", "root", "", "gothere");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// prepare and bind
$stmt = $conn->prepare("update people set people_cover = ? where people_uname = '" .$_SESSION['people_uname']."'" );
$stmt->bind_param("s", $image);
// set parameters and execute
$image = $_FILES['image']['name'];
$target_dir = "img/cover/";
$target_file = $target_dir . basename($_FILES['image']['name']);
//select file type
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
$extensions_arr= array("jpg", "jpeg", "png", "gif");
if (in_array($imageFileType,$extensions_arr)){
$stmt->send_long_data( move_uploaded_file($_FILES['image']['tmp_name'],$target_file.$name));
$stmt->execute();
if($stmt->affected_rows == 1){
echo "success";
}
exit();
//move_uploaded_file($_FILES['image']['tmp_name'],$target_file.$name);
$stmt->close();
$conn->close();
}
?>