-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofiles.php
62 lines (58 loc) · 1.93 KB
/
profiles.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
session_start();
error_reporting(0);
require_once 'connect.php';
if(isset($_SESSION['stuid']))
{
$stuid=strip_tags($_SESSION['stuid']);
$givd=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM users WHERE stuid='$stuid'"));
if($givd==true)
{
if(isset($_POST['submit']))
{
//file variables
$filename = $_FILES['File']['name'];
$venkateshfname = $_FILES['File']['name'];
$tmpname = $_FILES['File']['tmp_name'];
$filesize = $_FILES['File']['size'];
$ftype = $_FILES['File']['type'];
$extension=strpbrk($_FILES['File']['name'],".");
$vpb_file_extensions = pathinfo($filename, PATHINFO_EXTENSION); // File Extension
$vpb_allowed_file_extensions = array("jpg","jpeg","gif","png");
$startdate = strtotime("Monday");
$enddate = strtotime("+6 weeks",$startdate);
$d2=ceil(($d1-time())/60/60);
$d3=strrev("ABCDEFGHIJKLMNOPQSRTUVXYZ");
$date=date('Y-m-d').time();
$venkateshfname=$stuid."-".$date."_".$d3.".".$vpb_file_extensions;
$fp = fopen($tmpname, 'r');
$file = fread($fp, filesize($tmpname));
$file = addslashes($file);
fclose($fp);
$uploadDir = 'profiles/';
if (!in_array($vpb_file_extensions, $vpb_allowed_file_extensions))
{
//Display file type error error
echo "<script>alert('only jpg,jpeg,gif,png are allowed');window.location='index.php';</script>";
}
else
{
$filePath = $uploadDir . $venkateshfname;
$result = move_uploaded_file($tmpname, $filePath);
if (!$result) {
echo "<script>alert('Error uploading file..or file is too large or file is not an image format');window.location='index.php';</script>";
exit;
}
$query = mysqli_query($con,"UPDATE users SET profile='profiles/$venkateshfname' where stuid='$stuid' ") or die(mysql_error());
if ($query==true){
echo "<script>alert('Your Profile Picture has been updated successfully..!!!');window.location='index.php';</script>";
}
}
}
}
}
else
{
echo "<script>alert('Invalid');window.location='index.php';</script>";
}
?>