upload_gambar php
<form name="form" method="post" enctype="multipart/form-data" action="upload.php">
Gambar nu rek diaplodna : <input name="picture" type="file" />
<input type="submit" name="upload" value="Upload" />
</form>
buatsebuah file dengan nama upload.php
ini syntaxnya
<?php
include "konek.php";
$fileName = $_FILES['picture']['name'];
$fileSize = $_FILES['picture']['size'];
$fileError = $_FILES['picture']['error'];
if($fileSize > 0 || $fileError == 0){
$move = move_uploaded_file($_FILES['picture']['tmp_name'], 'G:/web/xampp/htdocs/Jenar/image/'.$fileName);
if($move){
echo "<h3>Skses Aplod! </h3>";
$q = "INSERT into poto VALUES('','$fileName','image/$fileName')";
$result = mysql_query($q);
$q1 = "SELECT location from poto where filename = '$fileName' limit 1 ";
$result = mysql_query($q1);
while ($data = mysql_fetch_array($result)) {
$loc = $data['location']; ?>
<br/>
<h2> Ieu Poto Bieu : </h2>
<img src="<?php echo $loc; ?>" /> < --> <?php
}
} else{
echo "<h3>Gagal! </h3>";
}
} else {
echo "Gagal Ngaplod : ".$fileError;
}
Label: php dan mysql, pmrograman
0 Komentar:
Posting Komentar
Berlangganan Posting Komentar [Atom]
<< Beranda