我有一点在 MAMP 上工作正常的代码,但在 WAMP 上给了我一个错误。代码是:
$uploads = "";
for($x=0; $x<$count_data; $x++)
{
$uploads .= $_FILES['file']['name'][$x] . ' ';
}
错误是:
注意:未定义的偏移量:1
注意:未定义的偏移量:2
注意:未定义的偏移量:3
注意:未定义的偏移量:4
有任何想法吗?
这是文件上传代码:
$number_of_file_fields = 0;
$number_of_uploaded_files = 0;
$number_of_moved_files = 0;
$uploaded_files = array();
$upload_directory = dirname(__file__) . '/../uploads/'; //set upload directory
$count_data=count($_FILES['file']) ;
$uploads = "";
for($x=0; $x<$count_data; $x++)
{
$uploads .= $_FILES['file']['name'][$x] . ' ';
}
for ($i = 0; $i < count($_FILES['file']['name']); $i++) {
$number_of_file_fields++;
if ($_FILES['file']['name'][$i] != '') { //check if file field empty or not
$number_of_uploaded_files++;
$uploaded_files[] = $_FILES['file']['name'][$i];
if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $upload_directory . $orderNumber . "_" . $_FILES['file']['name'][$i])) {
$number_of_moved_files++;
}
}
}