Home >php教程 >php手册 >PHP学习笔记:上传文件

PHP学习笔记:上传文件

WBOY
WBOYOriginal
2016-06-21 09:05:44827browse

笔记|上传

上传页:up.htm

表单项要加enctype=”multipart/form-date”

处理页:upload.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 "图片上传成功,点击查看";
?>



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn