heres the code im having problems with
<?php
if (!isset($_SESSION['username'])) {
$pfp_source = '/uploads/' ['fileToUpload'];
}
?>
<img id="profile-img" src="<?php "$pfp_source" ?>" style="width: 50%; float: left;">
<h5 id="name"><?php echo $username ?></h5>
i use
<?php require('../Account/upload.php') ?>
and upload php is this
<?php include('server.php') ?>
<?php
session_start();
if (!isset($_SESSION['username'])) {
$_SESSION['msg'] = "You must log in first";
header('location: Login.php');
}
$username = $_SESSION['username'];
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="navbar5">
<a class='btn5' href="../main.php">Main</a>
<a class='btn5' href="../Credits/">Credits</a>
<a class='btn5' href="../Chat/">Chat</a>
<a class='btn5' href="index.php">Profile</a>
</div>
<div id="content">
<form action="upload.php" method="post" class="form-act" enctype="multipart/form-data">
<style type="text/css">
color:white ;
</style>
<input type="file" class="fileToUpload" name='fileToUpload'>
<br/>
<input type="submit" value="upload" class="submit-image" name="submit-image">
</form>
</body>
</html>
<?php
$target_dir = "../Chat/uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if(isset($_POST["submit-image"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "";
$uploadOk = 1;
} else {
echo "";
$uploadOk = 0;
}
}
if (file_exists($target_file)) {
echo "";
$uploadOk = 0;
}
if ($_FILES["fileToUpload"]["size"] > 1000000) {
echo "ur file is too large";
$uploadOk = 0;
}
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg") {
echo "";
$uploadOk = 0;
}
if ($uploadOk == 0) {
echo "";
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename("image has been uploaded."));
} else {
echo "";
}
}
?>
so um in the index.php im having a problem in this place
<?php
if (!isset($_SESSION['username'])) {
$pfp_source = '/uploads/' ['fileToUpload'];
}
?>
<img id="profile-img" src="<?php "$pfp_source" ?>" style="width: 50%; float: left;">
<h5 id="name"><?php echo $username ?></h5>
because it says that the image source is (unknown) its empty for some reason idk why
<img id="profile-img" src="" style="width: 50%; float: left;">
that is what i see when going to the page i hope yall understand what i mean, i can upload full code of index.php and upload.php if needed
What I have tried:
i asked help from my friend but he didnt know and then i tried other stuff like changing the code to
<?php
if (!isset($_SESSION['username'])) {
$pfp_source = '/uploads/' ['tmp_name'];
}
?>
<img id="profile-img" src=<?php echo '"'.$pfp_source.'"' ?> style="width: 50%; float: left;">
<h5 id="name"><?php echo $username ?></h5>
in the chat aka index.php but didnt work it gave me the same result "(unknown)"