-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
48 lines (37 loc) · 1.41 KB
/
Copy pathupload.php
File metadata and controls
48 lines (37 loc) · 1.41 KB
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
<?php
session_start();
if(isset($_POST['submit'])){
$sessionname=$_SESSION['name'];
$profilepic=$_FILES['profilepic'];
$profilepic_Name=$_FILES['profilepic']['name'];
$profilepic_Type=$_FILES['profilepic']['type'];
$profilepic_Error=$_FILES['profilepic']['error'];
$profilepic_Size=$_FILES['profilepic']['size'];
$profilepic_Temp=$_FILES['profilepic']['tmp_name'];
$profilepic_Ext=explode('.',$profilepic_Name);
$profilepic_Actualext=strtolower(end($profilepic_Ext));
$allowed=array('jpg');
if(in_array($profilepic_Actualext,$allowed)){
if($profilepic_Error===0){
if($profilepic_Size<1000000){
$profilepic_Name_New='profile'.$sessionname.'.'.$profilepic_Actualext;
$profilepic_Destination='profilepic/'.$profilepic_Name_New;
move_uploaded_file($profilepic_Temp,$profilepic_Destination);
include('dbh.php');
$query="UPDATE signup Set profile_pic=1 where Username='$sessionname'";
$result=mysqli_query($dbc,$query);
header('location:profile.php?sucess!!');
}
else{
echo 'The file is too big to upload';
}
}
else{
echo 'Something went wrong during uploading';
}
}
else{
echo 'You cannot upload files of this type';
}
}
?>