Advertisement
Avatarr

new

Jun 13th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?
  2. include ("database.php");
  3. $db = new database;
  4. //Check if submit button exist and click
  5. if (isset($_POST['Submit'])) {
  6.     $title = $_POST["title1"];
  7.     $cat = $_POST["cat"];
  8.     $txt = $_POST["editor1"];
  9.     $image = $_FILES["file1"]["name"];
  10.     $post_by = $_SESSION['username'];
  11.     $time = date("d:m:Y");
  12.  
  13.  
  14.  
  15.     if ($image) {
  16.         if ((($_FILES["file1"]["type"] == "image/gif")
  17.                 || ($_FILES["file1"]["type"] == "image/jpeg")
  18.                 || ($_FILES["file1"]["type"] == "image/pjpeg")
  19.                 || ($_FILES["file1"]["type"] == "image/png")
  20.                 && ($_FILES["file1"]["size"] < 250000))) { // 250KB
  21.             // image storing folder, make sure you indicate the right path
  22.             $folder = "../thumbnail/";
  23. // creating a path
  24.             $path = $folder . $image;
  25.             if (file_exists($path)) {
  26.                 echo '"<script>alert("Image already exists.")</script>"';
  27.             } else {
  28.                 // image checking if exist or the input field is not empty
  29. // uploading image file to specified folder
  30.                 $c = copy($_FILES['file1']['tmp_name'], $path);
  31.             }
  32.         } else {
  33.             echo '"<script>alert("You type of image is error")</script>"';
  34.         }
  35.     }
  36. }
  37.  
  38.  
  39. $db->add_data("tbl_post", $title, $txt, $post_by, $cat, $time, $path);
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement