Php 不能使用多个文件输入字段。泽德

Php 不能使用多个文件输入字段。泽德,php,html,zend-framework,Php,Html,Zend Framework,似乎找不到我的问题,但我正试图做的是有一个项目组的编辑表单,它可以有4个图像。 当我试着上传所有四张图片时,效果很好,而当我只上传一张时,效果就不好了 代码:HTML表单 <?php $langs = $this->langs; $projectGroup = $this->projectGroup; ?> <div id="box"> <h3>Edit Project Group</h3> <fo

似乎找不到我的问题,但我正试图做的是有一个项目组的编辑表单,它可以有4个图像。 当我试着上传所有四张图片时,效果很好,而当我只上传一张时,效果就不好了

代码:HTML表单

<?php
    $langs = $this->langs;
    $projectGroup = $this->projectGroup;
?>
<div id="box">
    <h3>Edit Project Group</h3>
    <form id = "form" name = "form" action="<?php echo URLgenerator::getURL('project', 'group-edit', array('id' => $projectGroup->getId()), 'admin'); ?>" method="post" enctype='multipart/form-data'>
        <?php 
            foreach($langs as $lang):
                $langId = $lang->getId();
                $displayName = $lang->getDisplayName();
        ?>
            <fieldset id="In<?php echo $displayName; ?>">
                <legend id ="<?php echo $langId?>">
                    <?php echo $displayName; ?>: 
                </legend> 
                <label for="name-<?php echo $langId; ?>">Name: </label> 
                <input type="text" id="name-<?php echo $langId; ?>" name="name-<?php echo $langId; ?>" style="width: 500px;" value="<?php echo $projectGroup->getName($lang); ?>" />
                <br />
                <label for="imageOff-<?php echo $langId; ?>">Image Off: </label> 
                <input type="file" id="imageOff-<?php echo $langId; ?>" name="imageOff-<?php echo $langId; ?>" />
                <img src="<?php echo $projectGroup->getImageOffURL($lang); ?>" />
                <br />
                <label for="imageOn-<?php echo $langId; ?>">Image On: </label> 
                <input type="file" id="imageOn-<?php echo $langId; ?>" name="imageOn-<?php echo $langId; ?>" />
                <img src="<?php echo $projectGroup->getImageOnURL($lang); ?>" />
            </fieldset>
        <?php 
            endforeach;
        ?>
        <div align="center">
            <input type="submit" value="Edit" id="button1" /> 
            <input type="reset" id="button2" />
        </div>
    </form>
</div>

<script type="text/javascript">
    <?php 
        foreach($langs as $lang):
            $langId = $lang->getId();
    ?>
    $('#<?php echo $langId; ?>').click(function() {
        $('#div-<?php echo $langId; ?>').toggle();
    });
    <?php 
        endforeach;
    ?>
</script>
以及我在进行var_转储时得到的:

array
  'imageOff-1' => 
    array
      'name' => string '1.gif' (length=5)
      'type' => string 'application/octet-stream' (length=24)
      'tmp_name' => string 'C:\wamp\tmp\php95C1.tmp' (length=23)
      'error' => int 0
      'size' => string '2248' (length=4)
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean true
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)
  'imageOn-1' => 
    array
      'name' => string '' (length=0)
      'type' => null
      'tmp_name' => string '' (length=0)
      'error' => int 4
      'size' => null
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean false
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)
  'imageOff-2' => 
    array
      'name' => string '' (length=0)
      'type' => null
      'tmp_name' => string '' (length=0)
      'error' => int 4
      'size' => null
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean false
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)
  'imageOn-2' => 
    array
      'name' => string '' (length=0)
      'type' => null
      'tmp_name' => string '' (length=0)
      'error' => int 4
      'size' => null
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean false
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)
附言。 也许我可以通过使用这个临时名称并使用它来实现它,但是在正常情况下,我得到临时名称有一个正常的扩展名,而不是.tmp,所以我使用它作为扩展名。当我得到.tmp时,我什么也不做,因为它不是.jpg、.png或.gif(在我的上传功能中)


如果您也需要上传功能,请发表评论。

您可能需要将ignoreNoFile设置为true。看看这篇文章是否有用:

您可能需要将ignoreNoFile设置为true。看看这篇文章是否有用:

可能的重复
array
  'imageOff-1' => 
    array
      'name' => string '1.gif' (length=5)
      'type' => string 'application/octet-stream' (length=24)
      'tmp_name' => string 'C:\wamp\tmp\php95C1.tmp' (length=23)
      'error' => int 0
      'size' => string '2248' (length=4)
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean true
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)
  'imageOn-1' => 
    array
      'name' => string '' (length=0)
      'type' => null
      'tmp_name' => string '' (length=0)
      'error' => int 4
      'size' => null
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean false
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)
  'imageOff-2' => 
    array
      'name' => string '' (length=0)
      'type' => null
      'tmp_name' => string '' (length=0)
      'error' => int 4
      'size' => null
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean false
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)
  'imageOn-2' => 
    array
      'name' => string '' (length=0)
      'type' => null
      'tmp_name' => string '' (length=0)
      'error' => int 4
      'size' => null
      'options' => 
        array
          'ignoreNoFile' => boolean false
          'useByteString' => boolean true
          'magicFile' => null
          'detectInfos' => boolean true
      'validated' => boolean false
      'received' => boolean false
      'filtered' => boolean false
      'validators' => 
        array
          0 => string 'Zend_Validate_File_Upload' (length=25)
      'destination' => string 'C:/wamp/www/EfCom/public/tmp' (length=28)