[PHP文件上传下载]①--文件上传信息

2017-09-18  本文已影响9人  子木同
Paste_Image.png Paste_Image.png Paste_Image.png
<html>
<head><title></title></head>
<body>
<form action="doAction.php" method="post" enctype="multipart/form-data">
    请选择您要上传的文件:
    <input type="file" name="myFile"/><br/>
    <input type="submit" value="上传文件">
</form>
</body>
</html>

doAction.php

<?php
//$_FILES:文件上传信息

//var_dump($_FILES);
/**
 * array
 * 'myFile' =>
 * array
 * 'name' => string '新建文本文档.txt' (length=22)
 * 'type' => string 'text/plain' (length=10)
 * 'tmp_name' => string 'C:\wamp\tmp\php8A5F.tmp' (length=23)
 * 'error' => int 0
 * 'size' => int 5149
 */
$myFile = $_FILES['myFile'];
$filename = $myFile['name'];
$type = $myFile['type'];
$tmp_name = $myFile['tmp_name'];
$error = $myFile['error'];
$size = $myFile['size'];

//将服务器上的临时文件移动到指定目录下

//move_upload_file($tmp_name,$destination)
//成功返回true 否则返回false
//move_uploaded_file($tmp_name, "uploads/" . $filename);

//copy($src,$dst)
//成功返回true 否则返回false
copy($tmp_name, 'uploads/' . $filename);
Paste_Image.png Paste_Image.png
上一篇 下一篇

猜你喜欢

热点阅读