用如下语句上传文件时
<input type="file" name="document_file" value="" style="height:27px;"/>
能用如下语句获得上传了几个文件吗?
count($_FILES['document_file'])
<input type="file" name="document_file" value="" style="height:27px;"/>
能用如下语句获得上传了几个文件吗?
count($_FILES['document_file'])
{
$document_files = array($k => array(
'filename_'.$k => $_FILES['document_file'][$k]['name'],
'savename_'.$k => $document_code.time(),
)
);
$document_files = json_encode($document_files);
但不知道这样行不行
{
if(in_array($document_file['type'], array( 'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'text/csv')
))
{
$path = '/upload/documents/'.$document_filename;
if(file_exists(PROJECTPATH.'hosts/www'.$path) == TRUE)
{
@chmod(PROJECTPATH.'hosts/www'.$path, 0777);
@unlink(PROJECTPATH.'hosts/www'.$path);
if(move_uploaded_file($document_file['tmp_name'], PROJECTPATH.'hosts/www'.$path)){}
}
else
{
if(move_uploaded_file($document_file['tmp_name'], PROJECTPATH.'hosts/www'.$path)){}
}
}
}