<commit_before><?php
include "lib.php";
$db = getDBConnection();

if(isset($_POST['upload'])){

  $target="images/".basename($_FILES['image']['name']);

  $image=$_FILES['image']['name'];
//  $text=$_POST['text'];

  $sql="INSERT into `images` (`name`)VALUES ($image);";
  $res=$db->query($sql);

  if(move_uploaded_file($_FILES['image']['tmp_name'],$target))
  {
    echo "IMAGE UPLOADED Successfully";
  }

}
?>


//for testing
<!DOCTYPE html>
<html>
<head>

  <title>Image Upload</title>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
  $db=getDBConnection();
?>
<div id="content">
    <form method ="post" action="upload.php" enctype="multipart/form-data">
        <input type="hidden" name="size" value="1000000">
        <div>
          <input type ="file" name="image">
        </div>

        <div>
          <input type ="submit" name="upload" value="Upload image">
        </div>
      </form>
    </div>
  </body>
  </html>
<commit_msg>writes to DB and uploads<commit_after><?php
include "lib.php";
$db = getDBConnection();

if(isset($_POST['upload'])){

  $target="images/".basename($_FILES['image']['name']);

  $image=$_FILES['image']['name'];
//  $text=$_POST['text'];

  $sql="INSERT INTO `images` (`id`, `name`, `timestamp`) VALUES (NULL, '$image', CURRENT_TIMESTAMP);";

  $res=$db->query($sql);

  if(move_uploaded_file($_FILES['image']['tmp_name'],$target))
  {
    echo "IMAGE UPLOADED Successfully";
  }
  else {
    echo "Image not uploaded!! ";
  }
}
?>


//for testing
<!DOCTYPE html>
<html>
<head>

  <title>Image Upload</title>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
  $db=getDBConnection();
?>
<div id="content">
    <form method ="post" action="upload.php" enctype="multipart/form-data">
        <input type="hidden" name="size" value="1000000">
        <div>
          <input type ="file" name="image">
        </div>

        <div>
          <input type ="submit" name="upload" value="Upload image">
        </div>
      </form>
    </div>
  </body>
  </html>

{'fraction_non_alphanumeric': 0.21375807940904895, 'fraction_numerical': 0.006463527239150508, 'mean_word_length': 3.020408163265306, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6757566', 'n_tokens_mistral': 803, 'n_tokens_neox': 750, 'n_words': 144}