hi all,
i need to display the image that is selected when we browse from our local system..so can anyone help me...
thank u.
<html>
<body>
<form enctype="multipart/form-data" action="form.php" method="post">
<img src="" style="width:170px;height:200px">
<input type="file" size="15" name="imageupload">
</body>
</html>
---form.php----
if((!empty($_FILES["imageupload"])) && ($_FILES['imageupload']['error'] == 0)) {
//Check if the file is JPEG image and it's size is less than 350Kb
$filename = basename($_FILES['imageupload']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "jpg") && ($_FILES["imageupload"]["type"] == "image/jpeg") ) {
//Determine the path to which we want to save this file
$newname = dirname(__FILE__).'/images/'.$filename;
//Check if the file with the same name is already exists on the server
if (!file_exists($newname)) {
//Attempt to move the uploaded file to it's new place
if ((move_uploaded_file($_FILES['imageupload']['tmp_name'],$newname))) {
echo "The image has been uploaded as: ".$filename;
} else {
echo "Error: A problem occurred during images upload!";
}
} else {
echo "Error: image ".$_FILES["uploaded_file"]["name"]." already exists";
}
} else {
echo "Error: Only .jpg images are accepted for upload";
}
} else {
echo "Error: No image uploaded";
}