PHP文件上传示例
时间:2021-07-01 10:21:17
帮助过:49人阅读
处理代码: - header('Content-Type:text/html;charset=UTF-8');
- //准备接收
- /*
- echo '文件名:'new/2019-09-22-201922/$_FILES['userfile']['name'];
- echo '文件大小:'new/2019-09-22-201922/$_FILES['userfile']['size'];
- echo '错误:'new/2019-09-22-201922/$_FILES['userfile']['error']; */
-
- //print_r($_FILES)
- $tmpFile=$_FILES['userfile']['tmp_name'];
- if(is_uploaded_file($tmpFile))
- {
- echo '正在上传。。。';
-
-
- if(!file_exists('uploads'))//如果文件夹不存在
- {
- mkdir('uploads');
- }
- $moveFile =move_uploaded_file($tmpFile, 'uploads/'new/2019-09-22-201922/$_FILES['userfile']['name']);
-
- if($moveFile)
- {
- echo "移动成功!";
-
- //echo ' ';
-
- }else
- {
- echo '移动失败!';
- }
-
- }else
- {
- echo "临时文件夹找不到文件";
-
- }
- ?>
HMTL代码: -
-
-
-
- Insert title here
-
-
-
-
-
|
文件上传, PHP