vendredi 30 octobre 2015

How to Upload Multilevel Files in Php? [duplicate]

This question already has an answer here:

I have a form in in that i have to upload images. below is my form.

<form method="post" action="<?php echo $this->url(array('controller'=>'practice','action'=>'save-multiple-img'),'azend');?>" enctype="multipart/form-data">
<input name="name" type="text" />
  <input name="file['f_plan'][1][]" id="file" type="file"  />
  <input name="file['f_plan'][1][]" id="file" type="file"  />
  <input name="file['f_plan'][1][]" id="file" type="file"  />
  <input name="file['f_plan'][2][]" id="file" type="file" />
  <input name="file['f_plan'][2][]" id="file" type="file"  />
  <input name="file['f_plan'][3][]" id="file" type="file"  />
  <input name="file['f_plan'][3][]" id="file" type="file"  />
  <input type="submit" name="upload_images" value="Upload Images">
</form>

in My controller

  $apt    = new Zend_File_Transfer();
    $files  = $apt->getFileInfo();
    $post = $this->getRequest()->getPost();
    //$filterChain = new Zend_Filter();//print_r($_FILES['file']);die();
    foreach($_FILES['file']['name'] as $key => $tmp_name){
        foreach($tmp_name as $k => $value) {
            $apt->setDestination('images/practice/thumbs');
            $apt->addFilter('Rename', array('target' =>$post['name'],'overwrite' => true,'cropToFit'=>true));
             if ($apt->receive()) {
             }
             else{
             echo 'not uploaded<br>';die();
             }

        }
    }

While uploading files im getting Warnings like

Warning: file_exists() expects parameter 1 to be a valid path, array given in C:\xampp\htdocs\azend\library\Zend\File\Transfer\Adapter\Abstract.php on line 1283
Array to string conversion in C:\xampp\htdocs\azend\library\Zend\Validate\Abstract.php on line 233

Please Help me How to Upload these type of files!! Thanks in Advance

Aucun commentaire:

Enregistrer un commentaire