D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
upload_image.php
back
Copy
<?php include "../config.php"; ?> <?php // Check if the form is submitted if (isset($_POST['submit'])) { // File upload handling $uploadDirectory = "uploads/ashaar/"; // Directory to store uploaded images $targetFile = $uploadDirectory . basename($_FILES["image"]["name"]); if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFile)) { // Image uploaded successfully $imagePath = $targetFile; $dateOfPicture = $_POST['date']; $category = $_POST['category']; // Insert data into the 'pictures' table $sql = "INSERT INTO pictures (picture_path, date_of_picture, category) VALUES (?, ?, ?)"; $stmt = $conn->prepare($sql); $stmt->bind_param("sss", $imagePath, $dateOfPicture, $category); if ($stmt->execute()) { echo "Image uploaded and data inserted successfully."; } else { echo "Error: " . $conn->error; } } else { echo "Failed to upload the image."; } // Close the database connection $conn->close(); } ?>