吓一跳,太简单的PHP文件上传
被PHP的文件上传下了一跳,这是我写过的实现最简单的文件上传了(俺写过java\asp\c#)
<?php
$f=&$HTTP_POST_FILES['file'];
$dest_dir='uploads';//设定上传目录
$dest=$dest_dir.'/'.date("ymd")."_".$f['name']; //设置文件名为日期加上文件名避免重复
$r=move_uploaded_file($f['tmp_name'],$dest);
?>
<form action="index.php" enctype="multipart/form-data" method="POST">
<input type="file" name="file">
<input type="submit" />
</form>
$f=&$HTTP_POST_FILES['file'];
$dest_dir='uploads';//设定上传目录
$dest=$dest_dir.'/'.date("ymd")."_".$f['name']; //设置文件名为日期加上文件名避免重复
$r=move_uploaded_file($f['tmp_name'],$dest);
?>
<form action="index.php" enctype="multipart/form-data" method="POST">
<input type="file" name="file">
<input type="submit" />
</form>