<?php
include "connect2.php";
$fileName = $_FILES['picture']['name']; //get the file name
$fileSize = $_FILES['picture']['size']; //get the size
$fileError = $_FILES['picture']['error']; //get the error when upload
if($fileSize > 0 || $fileError == 0){ //check if the file is corrupt or error
$move = move_uploaded_file($_FILES['picture']['tmp_name'], 'C:\xampp\htdocs\SISFOGEREJA\imageuploaded/'.$fileName); //save image to the folder
if($move){
echo "<h3>Success! </h3>";
$q = "INSERT into tb_image VALUES('','$fileName','image/$fileName')"; //insert image property to database
$result = mysql_query($q);

$q1 = "SELECT location from tb_image where filename = '$fileName' limit 1 "; //get the image that have been uploaded
$result = mysql_query($q1);
while ($data = mysql_fetch_array($result)) {
$loc = $data['location']; ?>
<br/>
<h2> This is the Image : </h2>
<img src="<?php echo $loc; ?>" /> <!-- show the image using img src -->
<?php
}
} else{
echo "<h3>Failed! </h3>";
}
} else {
echo "Failed to Upload : ".$fileError;
}
?>
Share

Penulis : Dison Lumingkewas ~ || Dunia Seni

Artikel ini dipublish oleh Dison Lumingkewas pada hari Kamis, 18 April 2013. Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan
 

0 comments:

Posting Komentar

TERIMA KASIH ATAS KUNJUNGAN