笔记|上传
上传页:up.htm
表单项要加enctype=”multipart/form-date”
<form method=”post” action=”upload.php” enctype=”multipart/form-data”>
<input type=”file” name=”file”>
<input type=”submit” value=”Submit”>
</form>
处理页:upload.php
<?php
$f=$HTTP_POST_FILES['file'];
$dest_dir='uploads';
$dest=$dest_dir."/".date("ymd")."-".$f['name'];//文件夹+日期+文件名,防止因重名被覆盖.
$r=move_uploaded_file($f['tmp_name'],$dest); //move_upload_file(上传文件名,上传目录)
chmod($dest,0755); //设定文件权限chmod(文件名,权限一般是八进制的0755)
echo "图片上传成功,<a href=".$dest." target=_blank>点击查看</a>";
?>