Upload an image into a folder

For upload an image into a folder from antother folder
you have to simply copy this code and paste this code on your new pahe of php.
and run the page on browser..



<?php
$target="images/";
$target= $target.basename($_FILES['file']['name']);
$img_name=basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'],$target))
{
echo "the file name ".basename($_FILES['file']['name'])."has been uploaded";
}
else
{
echo " downloaded error";
} ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="" name="upload" enctype="multipart/form-data" method="post">
image <input type="file" name="file" id="file" /><br/><br/>
<input type="submit" name="submit" id="submit" />
</form>
</body></html>

Comments