after press submit button to upload the image, the information will display at new window, i need the information will be display below submit button.
my code:
<?php
if($_GET['action'] == "upload")
{
?>
<div id="upload">
<br/><br/>
<form action="upload_image.php?action=upload" method="post" enctype="multipart/form-data">
<label for="file">Gambar yang ingin dimuat naik:</label>
<input type="file" name="file" id="file"><br><br/>
<input type="submit" name="submit" value="Submit" id="submit_upload"><br/><br/>
</form>
</div>
<?php
$allowedExts = array("gif", "jpeg", "jpg", "png");
$value = explode(".", $_FILES["file"]["name"]);
$extension = end($value);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
//&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
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>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
$_POST = array_map("mysql_real_escape_string", $_POST);
//if ($img = $_FILES["file"]["tmp_name"]) {
//$image_url = md5_file($img) . ".jpeg";
if(move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]))
{
//klu berjaya upload , then simpan nama kt database
$conn = mysql_connect('localhost','root','');
mysql_select_db('daftar',$conn);
$link = "http://localhost/form/admin2/upload/" . $_FILES["file"]["name"];;
$sql = "insert into images (image,link) values ('".$_FILES['file']['name']."','".$link."')";
if(mysql_query($sql))
{
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
else
{
echo 'File name not stored in database';
}
}
}
}
}
else
{
echo "Invalid file";
}
}
else
{
?>
<?php
require("../global.php");
echo "<title>".$title2."</title>";
echo "<link rel='stylesheet' type='text/css' href='style.css' />";
echo"
<div id='upload'>
<br/><br/>
<form action='upload_image.php?action=upload' method='post' enctype='multipart/form-data'>
<label for='file'>Gambar yang ingin dimuat naik:</label>
<input type='file' name='file' id='file'><br><br/>
<input type='submit' name='submit' value='Submit' id='submit_upload'><br/><br/>
</form>
</div>
";
}
?>