| Server IP : 199.79.63.27 / Your IP : 216.73.216.250 Web Server : Microsoft-IIS/10.0 System : Windows NT MD-PLESK-WEB5 10.0 build 20348 (Windows Server 2022) AMD64 User : IWPD_6698(lcitec7i) ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/INETPUB/VHOSTS/lcit.edu.in/lcitps.edu.in/ |
Upload File : |
<?php
include 'db.php'; // Ensure this file sets up $conn correctly
// Define target directory
$imageDir = "assets/images/blog/";
// Get file path
$imageFile = $imageDir . basename($_FILES["image"]["name"]);
// Move uploaded image file
if (move_uploaded_file($_FILES["image"]["tmp_name"], $imageFile)) {
// Escape file path for SQL
$imagePath = $conn->real_escape_string($imageFile);
// Insert into database
$sql = "INSERT INTO print_media (image_name) VALUES ('$imagePath')";
if ($conn->query($sql) === TRUE) {
echo "Image uploaded and saved successfully!";
header("Location:add_news.php");
exit(); // Important to stop further execution after redirect
} else {
echo "Database error: " . $conn->error;
}
} else {
echo "File upload failed.";
}
$conn->close();
?>