这样一段代码<?php
$a = 'upload/'.$_FILES['name']['name'];
move_uploaded_file($_FILES['name']['tmp_name'],$a);
?>想问下$_FILES[][]数组第2个参数都是一样的吗?第一个参数使用POST传递过来的。
$a = 'upload/'.$_FILES['name']['name'];
move_uploaded_file($_FILES['name']['tmp_name'],$a);
?>想问下$_FILES[][]数组第2个参数都是一样的吗?第一个参数使用POST传递过来的。
(
[file1] => Array
(
[name] => MyFile.txt (comes from the browser, so treat as tainted)
[type] => text/plain (not sure where it gets this from - assume the browser, so treat as tainted)
[tmp_name] => /tmp/php/php1h4j1o (could be anywhere on your system, depending on your config settings, but the user has no control, so this isn't tainted)
[error] => UPLOAD_ERR_OK (= 0)
[size] => 123 (the size in bytes)
) [file2] => Array
(
[name] => MyFile.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php/php6hst32
[error] => UPLOAD_ERR_OK
[size] => 98174
)
)Last I checked (a while ago now admittedly), if you use array parameters in your forms (that is, form names ending in square brackets, like several file fields called "download[file1]", "download[file2]" etc), then the array format becomes... interesting.Array
(
[download] => Array
(
[name] => Array
(
[file1] => MyFile.txt
[file2] => MyFile.jpg
) [type] => Array
(
[file1] => text/plain
[file2] => image/jpeg
) [tmp_name] => Array
(
[file1] => /tmp/php/php1h4j1o
[file2] => /tmp/php/php6hst32
) [error] => Array
(
[file1] => UPLOAD_ERR_OK
[file2] => UPLOAD_ERR_OK
) [size] => Array
(
[file1] => 123
[file2] => 98174
)
)
)So you'd need to access the error param of file1 as, eg $_Files['download']['error']['file1']
* $_FILES["file"]["type"] - 被上传文件的类型
* $_FILES["file"]["size"] - 被上传文件的大小,以字节计
* $_FILES["file"]["tmp_name"] - 存储在服务器的文件的临时副本的名称
* $_FILES["file"]["error"] - 由文件上传导致的错误代码<?
php $a = 'upload/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$a);
?>
http://www.w3school.com.cn/php/php_file_upload.asp