Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="description" content="">
- <meta name="author" content="">
- <title>Image Uploader</title>
- <!-- Bootstrap Core CSS -->
- <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
- <!-- Custom CSS -->
- <link href="custom.css" rel="stylesheet">
- </head>
- <body>
- <nav class="navbar navbar-inverse navbar" role="navigation">
- <div class="container">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header" id="fkj">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="#">Book Shopping</a>
- </div>
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
- <ul class="nav navbar-nav">
- <li>
- <a href="#">Add Products</a>
- </li>
- <li>
- <a href="#">My Cart</a>
- </li>
- <li>
- <a href="adminPanel.html">Admin Panel</a>
- </li>
- </ul>
- </div>
- <!-- /.navbar-collapse -->
- </div>
- <!-- /.container -->
- </nav>
- <div class="col-md-2"style="margin-left:0px;border-right:1px solid #cacdd1;">
- <ul class="nav nav-pills nav-stacked">
- <li><a href="#">Image Upload</a></li>
- <hr style="margin:2px;">
- <li><a href="#">Menu Number1</a></li>
- <hr style="margin:2px;">
- <li><a href="#">Menu Number2</a></li>
- <hr style="margin:2px;">
- <li><a href="#">Menu Number3</a></li>
- <hr style="margin:2px;">
- <li><a href="#">Menu Number4</a></li>
- <hr style="margin:2px;">
- <li><a href="#">Menu Number5</a></li>
- <hr style="margin:2px;">
- <li><a href="#">Menu Number6</a></li>
- <hr style="margin:2px;">
- </ul>
- </div>
- <div class="col-md-8" align="center">
- <form action="" method="post" enctype="multipart/form-data">
- Your Photo: <input type="file" name="photo" size="25" />
- <input type="submit" name="submit" value="Submit" />
- </form>
- </div>
- <?php
- if(isset($_POST["submit"])) {
- if($_FILES['photo']['name'])
- {
- //if no errors...
- if(!$_FILES['photo']['error'])
- {
- $valid_file=true;
- //now is the time to modify the future file name and validate the file
- $new_file_name = strtolower($_FILES['photo']['tmp_name']); //rename file
- if($_FILES['photo']['size'] > (1024000)) //can't be larger than 1 MB
- {
- $valid_file = false;
- $message = 'Oops! Your file\'s size is to large.';
- }
- //if the file has passed the test
- if($valid_file)
- {
- echo $_FILES['photo']['tmp_name'];
- //move it to where we want it to be
- move_uploaded_file($_FILES['photo']['tmp_name'], 'uploads/'.$_FILES['photo']['name']);
- $message = 'Congratulations! Your file was accepted.';
- }
- }
- //if there is an error...
- else
- {
- //set that to be the returned message
- $message = 'Ooops! Your upload triggered the following error: '.$_FILES['photo']['error'];
- }
- }
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "project0";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql= "INSERT into saleproductoffers(productImage)VALUES('uploads/".$_FILES['photo']['name']."')";
- $result = $conn->query($sql);
- }
- //$sql = "SELECT productImage FROM saleproductoffers where productPrice='6000'";
- ?>
- <!-- Bootstrap Core JavaScript -->
- <script src="js/bootstrap.min.js"></script>
- </body>
- <footer>
- </footer>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement