/
home
/
techb158
/
immovalet.ca
/
report
/
Master
/
Inc
/
/home/techb158/immovalet.ca/report/Master/Inc
mkdir
upload
Name
Size
Mode
Actions
Publish_Post.php
5994
0666
edit
dl
rm
Update_Profile.php
3556
0666
edit
dl
rm
Update_Publish_Post.php
6318
0666
edit
dl
rm
upload.php
2458
0666
edit
dl
rm
Edit:
/home/techb158/immovalet.ca/report/Master/Inc/upload.php
(2458B)
<?php //include_once '../includes/db_connect.php'; //include_once '../includes/psl-config.php'; include_once '../includes/db_connect.php'; include_once '../includes/functions.php'; sec_session_start(); //$target_dir = "Client/dist/img"; echo $_FILES['file']; //if(isset($_POST["submits"]) && isset($_FILES['file'])) { if(isset($_FILES['file'])) { echo $_FILES['file']; //$_POST["user_image"]; //$imgFile = $_POST['file']['name']; $tmp_dir = $_FILES['file']['tmp_name']; $imgSize = $_FILES['file']['size']; $imgFile = $_FILES['file']['name']; if(empty($imgFile)){ //$errMSG = "Please Select Image File."; header('Location: modifier_profil.php?error=Please Select Image File.'); exit(); } else { // $upload_dir = 'img/'; // upload directory $Admin_ID= $_SESSION['user_id']; $target = './img'; // upload directory $upload_dir=$target.'/'.$Admin_ID; if (!file_exists($upload_dir)) { mkdir($upload_dir, 0777); } $upload_dir=$upload_dir.'/'; $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension // valid image extensions $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions // rename uploading image $userpic = rand(1000,1000000).".".$imgExt; // allow valid image file formats if(in_array($imgExt, $valid_extensions)){ // Check file size '5MB' if($imgSize < 5000000) { move_uploaded_file($tmp_dir,$upload_dir.$userpic); } else{ $errMSG = "Sorry, your file is too large."; // header('Location: modifier_profil.php.php?error=Sorry, your file is too large.'); // exit(); // echo "Sorry, your file is too large"; } } else{ //header('Location: modifier_profil.php.php?error=Sorry, only JPG, JPEG, PNG & GIF files are allowed.'); //exit(); $errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; } } // if no error occured, continue .... if(!isset($errMSG)) { $username = $_SESSION['username']; if ($mysqli->query("UPDATE Master SET User_img ='$userpic' WHERE Username ='".$username."'")) { //header('Location: modifier_profil.php.php?error=new record succesfully inserted'); //exit(); } else { //header('Location: modifier_profil.php.php?error=error while inserting....'); //exit(); $errMSG = "error while inserting...."; } } } ?>
Save
cmd:
run