<?
//file name = up_pic.php
print_r($_FILES);
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<form name="sysform" enctype="multipart/form-data" method="post" action="up_pic.php" >
Image path<input type="file" name='up_pic_name'>
<input type="text" name="action" value='test'>
<input type="submit" value="Upload">
</form>
</body>
</html>
<?php
if($_FILES)
{
$p_url = "./pic/";//上傳路徑 //Upload Path
if($_FILES['up_pic_name']['name'] != '')
{
if(file_exists($p_url.basename($_FILES['up_pic_name']['name'])))
echo "File already exists";
else
move_uploaded_file($_FILES['up_pic_name']['tmp_name'],$p_url.basename($_FILES['up_pic_name']['name']));
}
}
?>
沒有留言:
張貼留言