Hello guys,
In this code you will learn on how to upload image using PHP/MySQL.
Import the image_upload.sql into MySQL.
Hope that you will like this code. If you have question about this code, email me at
[email protected].
Thank you.
Sample Code:
<?php
include('header.php');
?>
<body>
<br>
<br>
<div class="container">
<div class="row-fluid">
<div class="span12">
<form class="form-horizontal" method="POST" enctype="multipart/form-data">
<div class="control-group">
<label class="control-label" for="input01">Image:</label>
<div class="controls">
<input type="file" name="image" class="font" required>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" name="submit" class="btn btn-success">Upload</button>
</div>
</div>
</form>
</div>
<div class="span12">
<ul class="thumbnails">
<?php
?>
<li class="span2">
<div class="thumbnail"> <img src="<?php echo $row['location']; ?>" width="100" height="100" alt="" class="img-rounded"> </div>
</li>
<?php
}
?>
</ul>
</div>
</div>
<?php
if (isset($_POST['submit'])) {
$image_name = addslashes($_FILES['image']['name']);
$location = "upload/" . $_FILES["image"]["name"];
values ('$location')
}
?>
</div>
</body>
</html>
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.