<?php $user=$_SESSION['dbUser']['username']; $db=new mysqli('host','username','password','database'); if($db->connect_errno){ echo $db->connect_error;} $pull="select * from users where user='$user'"; $allowedExts = array("jpg", "jpeg", "gif", "png","JPG","PNG"); $extension = @end(explode(".", $_FILES["file"]["name"])); if(isset($_POST['pupload'])){ if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/JPG") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/PNG")) && ($_FILES["file"]["size"] < 200000000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Uploaded Successully<br>"; echo "It may take up to half an hour to update.<br><br>"; if (file_exists("upload/" . $_SESSION['dbUser']['username'])) { unlink("upload/" . $_SESSION['dbUser']['username'].".".$ext); } else { $pic=$_FILES["file"]["name"]; $conv=explode(".",$pic); $ext=$conv['1']; move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_SESSION['dbUser']['username'].".jpg"); $url=$user.".jpg"; $query="update picture set url='$url', lastUpload=now() where user='$user'"; if($upl=$db->query($query)){ header('Location: ' . $_SERVER['HTTP_REFERER']); } } } } else { echo "File Size Limit Crossed 200 KB Use Picture Size less than 200 KB"; } } ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)