Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(-1);
- if (isset($_POST['gallery-upload'])) {
- $hostname='**';
- $username='**';
- $password='**';
- $file = $_FILES['image'] ['tmp_name'];
- $tmpName = $_FILES['image']['tmp_name'];
- $filter = $_POST['filter'];
- $fp = fopen($tmpName, 'rb');
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=dddoecje_campu",$username,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- $stmt = $dbh->prepare("INSERT INTO `gallery`(`id`, `image`, `filter`) VALUES ('',:image,:filter)");
- $stmt->bindParam(':filter', $filter);
- $stmt->bindParam(':image', $fp, PDO::PARAM_LOB);
- $dbh->errorInfo();
- $stmt->execute();
- // use exec() because no results are returned
- header("Location: index.php");
- }
- catch(PDOException $e)
- {
- echo $sql . "<br>" . $e->getMessage();
- }
- $dbh = null;
- }
- ?>
- <div class="col-md-4">
- <div class="panel panel-default">
- <div class="panel-body">
- <form action="upload-gallery.php" method="post" enctype="multipart/form-data">
- <div class="form-group">
- <i class="icon-cloud-upload"></i>
- <span>Select file</span>
- <input type="file" accept="image/png, image/jpeg, image/gif" data-max-size="5000" name="image">
- </div>
- <select name="filter">
- <option value="all">All</option>
- <option value="area">Area</option>
- <option value="resort">Resort</option>
- <option value="rinjani">Rinjani</option>
- </select>
- <button style="margin-top: 10px;" name="gallery-upload" class="btn btn-default"><?php echo $upload_gallery;?></button>
- </form>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement