iceyfox.xyz/chat/profile_update.php

33 lines
1.1 KiB
PHP
Executable File

<html>
<body>
<?php
session_start();
require_once("../login/login.php");
if($login_correct=="true"){
if(isset($_POST['pfp_change'])){
$file_type = strtolower(pathinfo($_FILES["pfp_picture"]["name"],PATHINFO_EXTENSION));
if($file_type=="png"||$file_type=="jpg"||$file_type=="gif"){
if($_FILES["pfp_picture"]["size"] < 3000000){
unlink("../account_data/".$_SESSION['username'].".png");
unlink("../account_data/".$_SESSION['username'].".jpg");
unlink("../account_data/".$_SESSION['username'].".gif");
if(move_uploaded_file($_FILES["pfp_picture"]["tmp_name"], "../account_data/".$_SESSION['username'].".".$file_type)) {
$_SESSION['message']="file uploaded";
} else {
$_SESSION['message']="there was a error uploading your file";
}
} else {
$_SESSION['message']="file is too big, must be less than 5mb";
}
} else {
$_SESSION['message']="file is not a image or gif, try again";
}
}
} else {
echo $_SESSION['message']="error. you cant edit a profile that isn't yours. nice try";
}
?>
<script language="javascript" type="text/javascript">window.close();</script>
</body>
</html>