Related Code:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$permited = array('jpg', 'jpeg', 'png', 'gif');
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_temp = $_FILES['image']['tmp_name'];
$div = explode('.', $file_name);
$file_ext = strtolower(end($div));
$unique_image = substr(md5(time()), 0, 10).'.'.$file_ext;
$uploaded_image = "uploads/".$unique_image;
move_uploaded_file($file_temp, $uploaded_image);
$query = "INSERT INTO tbl_image(image)
VALUES('$uploaded_image')";
$inserted_rows = $db->insert($query);
if ($inserted_rows) {
echo "<span class='success'>Image Inserted Successfully.
</span>";
}else {
echo "<span class='error'>Image Not Inserted !</span>";
}
}
?>
How to practice tutorials…
- Make a team with your friends (Member should be 4/5).
- Start to practice one tutorial series along with them.
- Don’t try to collect source code. Type the code while watching the tutorial.
- If you face any problem, discuss with team members to solve quickly.