用如下语句上传文件时
<input type="file"  name="document_file" value="" style="height:27px;"/> 
能用如下语句获得上传了几个文件吗?
count($_FILES['document_file']) 

解决方案 »

  1.   

    但我想这样,当我执行保存所有内容的时候$document_file = @$_FILES['document_file'];foreach($document_file AS $k=>$v)
    {
    $document_files = array($k  => array(
    'filename_'.$k  => $_FILES['document_file'][$k]['name'],
    'savename_'.$k  => $document_code.time(),
    )
    );
    $document_files = json_encode($document_files);
    但不知道这样行不行
      

  2.   

    <input type="file" name="document_file" value="" style="height:27px;"/>  怎么我用如上的代码的时候,每次只能上传一个文件呢?
      

  3.   

    <input type="file" name="document_file" value="" style="height:27px;"/>  只能上传一个,可以多写几个<input type="file">
      

  4.   

    那我用 $document_file = (array)@$_FILES['document_file'];这句接收几个上传文件,然后怎么将这几个上传到指定目录下呢? 因为执行下面代码会提示要求的是字符串,但提供的是数组。if(is_uploaded_file($document_file['tmp_name']))
    {
    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)){}
    }
    }
    }