<form method="post" action="<?php echo $PHP_SELF; ?>" name="img_name" enctype="multipart/form-data">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr><td height="30" colspan="2"> </td></tr>
<tr><td height="30" align="right">圖片名稱﹕ </td><td height="20" align="left"><input name="name" type="text" size="20" /></td></tr>
<tr><td height="30" align="right">上傳圖片﹕ </td><td height="20" align="left"><input name="userfile" type="file" size="20" /></td></tr>
<tr><td height="30"> </td><td height="20" align="left"><input name="img" type="submit" value="提交" /></td></tr>
</table>
</form>
<?php
if($_POST['img'] && $_FILES)
{
$uploaddir = '/var/www/html/img/photos/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo "文件上傳成功! n<br>";
}
else
{
echo "文件上傳失敗!n";
}
}
?>