php
Upload Image in a folder Using PHP code
Upload Image in a folder Using PHP code
<?php
// Assigning value about your server to variables for database connection
if($_POST)
{
// check if file already exit in "images" folder.
//move_uploaded_file function will upload your image. if you want to resize image before uploading see this link http://b2atutorials.blogspot.com/2013/06/how-to-upload-and-resize-image-for.html
if(move_uploaded_file($_FILES["file"]["tmp_name"],"images/" . $_FILES["file"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$images=$_FILES["file"]["name"];
echo "Stored in: " . "images/" . $images;
}
else
{
echo 'File name not stored in database';
}
}
?>
<html>
<body>
<form action="" method="post"enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
0 comments