<?php
if (count($_FILES) > 0) {
if (is_uploaded_file($_FILES['userImage']['tmp_name'])) {
$imgData = addslashes(file_get_contents($_FILES['userImage']['tmp_name']));
$imageProperties = getimageSize($_FILES['userImage']['tmp_name']);
$sql = "INSERT INTO qr(user_id,file_name ,QrCode)
VALUES('".$_SESSION['id']."','{$imageProperties['mime']}', '{$imgData}')";
$current_id = mysqli_query($db, $sql) or die("<b>Error:</b> Problem on Image Insert<br/>" . mysqli_error($db));
if (isset($current_id)) {
header("Location: preview.php");
}
}
}
?>
<form name="frmImage" enctype="multipart/form-data" action=""
method="post" class="frmImageUpload">
<label>Upload QrCode File:</label><br /> <input name="userImage"
type="file" class="inputFile" /> <input type="submit"
value="Submit" class="btnSubmit" />
</form>
<?php
require_once '../php_action/database.php';
if(isset($_GET['image_id'])) {
$sql = "SELECT file_name , QrCode FROM qr WHERE id=" . $_GET['image_id'] . mysqli_error(($db)). mysqli_error(($db));
$result = mysqli_query($db, $sql) or die("<b>Error:</b> Problem on Retrieving Image BLOB<br/>" . mysqli_error($db));
$row = mysqli_fetch_array($result);
header("Content-type: " . $row["file_name"]);
echo $row["QrCode"];
}
mysqli_close($db);
?>
skymhine 0 Newbie Poster
skymhine 0 Newbie Poster
AndrisP 193 Posting Pro in Training
Dani 4,312 The Queen of DaniWeb Administrator Featured Poster Premium Member
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.