Advertisement
rootUser

imageDB.php (up and side nav)

Nov 29th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.53 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">
  7.     <meta name="description" content="">
  8.     <meta name="author" content="">
  9.  
  10.     <title>Image Uploader</title>
  11.  
  12.     <!-- Bootstrap Core CSS -->
  13.     <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  14.  
  15.     <!-- Custom CSS -->
  16.     <link href="custom.css" rel="stylesheet">
  17.  
  18. </head>
  19. <body>
  20. <nav class="navbar navbar-inverse navbar"  role="navigation">
  21.     <div class="container">
  22.         <!-- Brand and toggle get grouped for better mobile display -->
  23.         <div class="navbar-header" id="fkj">
  24.             <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  25.                 <span class="sr-only">Toggle navigation</span>
  26.                 <span class="icon-bar"></span>
  27.                 <span class="icon-bar"></span>
  28.                 <span class="icon-bar"></span>
  29.             </button>
  30.             <a class="navbar-brand" href="#">Book Shopping</a>
  31.         </div>
  32.         <!-- Collect the nav links, forms, and other content for toggling -->
  33.         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  34.             <ul class="nav navbar-nav">
  35.                 <li>
  36.                     <a href="#">Add Products</a>
  37.                 </li>
  38.                 <li>
  39.                     <a href="#">My Cart</a>
  40.                 </li>
  41.                 <li>
  42.                     <a href="adminPanel.html">Admin Panel</a>
  43.                 </li>
  44.             </ul>
  45.         </div>
  46.         <!-- /.navbar-collapse -->
  47.     </div>
  48.     <!-- /.container -->
  49. </nav>
  50. <div class="col-md-2"style="margin-left:0px;border-right:1px solid #cacdd1;">
  51.     <ul class="nav nav-pills nav-stacked">
  52.         <li><a href="#">Image Upload</a></li>
  53.         <hr style="margin:2px;">
  54.         <li><a href="#">Menu Number1</a></li>
  55.         <hr style="margin:2px;">
  56.         <li><a href="#">Menu Number2</a></li>
  57.         <hr style="margin:2px;">
  58.         <li><a href="#">Menu Number3</a></li>
  59.         <hr style="margin:2px;">
  60.         <li><a href="#">Menu Number4</a></li>
  61.         <hr style="margin:2px;">
  62.         <li><a href="#">Menu Number5</a></li>
  63.         <hr style="margin:2px;">
  64.         <li><a href="#">Menu Number6</a></li>
  65.         <hr style="margin:2px;">
  66.     </ul>
  67. </div>
  68.  
  69. <div class="col-md-8" align="center">
  70.     <form action="" method="post" enctype="multipart/form-data">
  71.         Your Photo: <input type="file" name="photo" size="25" />
  72.         <input type="submit" name="submit" value="Submit" />
  73.     </form>
  74. </div>
  75. <?php
  76.  
  77. if(isset($_POST["submit"])) {
  78.     if($_FILES['photo']['name'])
  79.     {
  80.         //if no errors...
  81.         if(!$_FILES['photo']['error'])
  82.         {
  83.             $valid_file=true;
  84.             //now is the time to modify the future file name and validate the file
  85.             $new_file_name = strtolower($_FILES['photo']['tmp_name']); //rename file
  86.             if($_FILES['photo']['size'] > (1024000)) //can't be larger than 1 MB
  87.             {
  88.                 $valid_file = false;
  89.                 $message = 'Oops!  Your file\'s size is to large.';
  90.             }
  91.  
  92.  
  93.             //if the file has passed the test
  94.             if($valid_file)
  95.             {
  96.                 echo $_FILES['photo']['tmp_name'];
  97.                 //move it to where we want it to be
  98.                 move_uploaded_file($_FILES['photo']['tmp_name'], 'uploads/'.$_FILES['photo']['name']);
  99.                 $message = 'Congratulations!  Your file was accepted.';
  100.             }
  101.         }
  102.         //if there is an error...
  103.         else
  104.         {
  105.             //set that to be the returned message
  106.             $message = 'Ooops!  Your upload triggered the following error:  '.$_FILES['photo']['error'];
  107.         }
  108.     }
  109.     $servername = "localhost";
  110.     $username = "root";
  111.     $password = "";
  112.     $dbname = "project0";
  113.  
  114. // Create connection
  115.     $conn = new mysqli($servername, $username, $password, $dbname);
  116. // Check connection
  117.     if ($conn->connect_error) {
  118.         die("Connection failed: " . $conn->connect_error);
  119.     }
  120.     $sql= "INSERT into saleproductoffers(productImage)VALUES('uploads/".$_FILES['photo']['name']."')";
  121.     $result = $conn->query($sql);
  122. }
  123.  
  124. //$sql = "SELECT productImage FROM saleproductoffers where productPrice='6000'";
  125.  
  126. ?>
  127. <!-- Bootstrap Core JavaScript -->
  128. <script src="js/bootstrap.min.js"></script>
  129. </body>
  130. <footer>
  131.  
  132. </footer>
  133. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement