Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- include ("database.php");
- $db = new database;
- //Check if submit button exist and click
- if (isset($_POST['Submit'])) {
- $title = $_POST["title1"];
- $cat = $_POST["cat"];
- $txt = $_POST["editor1"];
- $image = $_FILES["file1"]["name"];
- $post_by = $_SESSION['username'];
- $time = date("d:m:Y");
- if ($image) {
- if ((($_FILES["file1"]["type"] == "image/gif")
- || ($_FILES["file1"]["type"] == "image/jpeg")
- || ($_FILES["file1"]["type"] == "image/pjpeg")
- || ($_FILES["file1"]["type"] == "image/png")
- && ($_FILES["file1"]["size"] < 250000))) { // 250KB
- // image storing folder, make sure you indicate the right path
- $folder = "../thumbnail/";
- // creating a path
- $path = $folder . $image;
- if (file_exists($path)) {
- echo '"<script>alert("Image already exists.")</script>"';
- } else {
- // image checking if exist or the input field is not empty
- // uploading image file to specified folder
- $c = copy($_FILES['file1']['tmp_name'], $path);
- }
- } else {
- echo '"<script>alert("You type of image is error")</script>"';
- }
- }
- }
- $db->add_data("tbl_post", $title, $txt, $post_by, $cat, $time, $path);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement