Yen sira kasinungan ngelmu kang marakake akeh wong seneng, aja sira malah rumangsa pinter, jalaran menawa Gusti mundhut bali ngelmu kang marakake sira kaloka iku, sira uga banjur kaya wong sejene, malah bisa aji godhong jati aking.(Bila anda mendapat anugrah ilmu yang membuat banyak orang senang, janganlah kamu merasa pintar, sebab apabila Tuhan mengambil lagi ilmu yang menyebabkan anda terkenal itu, anda akan menjadi orang biasa lagi, malah lebih bermanfaat daun yang kering)
Wednesday, May 12, 2010
Contoh PHP Upload Gambar
<form action="upload2.php" method="post"
enctype="multipart/form-data">
<label for="file"></label>
<div align="center">
<table width="363">
<tr>
<td width="80" bgcolor="#CCCCCC"><label for="label">File*</label></td>
<td width="267" bgcolor="#CCCCCC"><input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td bgcolor="#999999">Ket</td>
<td bgcolor="#999999"><label>
<input name="ket" type="text" id="ket" size="30">
</label></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">gamber ke </td>
<td bgcolor="#CCCCCC"><label>
<select name="ke" id="ke">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</label></td>
</tr>
</table>
<br />
<input type="submit" name="submit" value="Submit" />
</div>
</form>
upload2.php
<html><style type="text/css">
<!--
.style2 {font-size: 24px;
font-weight: bold;
}
-->
</style>
<body>
<div align="center">
<p><span class="style2">Edit Harga GAMBAR </span></p>
<p>
<?php
if ((($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"../images/" . "rumah" . "$_POST[ke]" . ".jpg");
echo "Stored in: " . "../images/" . "rumah" . "$_POST[ke]" . ".jpg";
}
}
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tes", $con);
mysql_query("UPDATE data SET value = '$_POST[ket]'". "WHERE id = $_POST[ke]+14");
echo "<br>Data Telah Tersimpan";
mysql_close($con);
}
else
{
echo "Invalid file";
}
?>
</p>
</div>
</body>
</html>
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.