Rain
Rain

Reputation: 601

How to choose multi files and get path of it to handle - php - zend framework

I wanna choose multi files with zend_form and get full path of its to handle in my action. But I can't choose multi files as I need, just one file I can choose, and when submitted I catch an error "File 'videos' exceeds the defined ini size". Checking the page with Firebug, I see:

    <input type="hidden" id="MAX_FILE_SIZE" value="2097152" name="MAX_FILE_SIZE">
  1. how to choose multi file /2.how to get physical paths of files? / this is my form

     $videos = new Zend_Form_Element_File('videos');
     $videos->setLabel('Videos:')
     ->addValidator('Count', false, array('min' => 1, 'max' => 10))
     ->addFilter('StringTrim')
     ->addValidator('NotEmpty')
     ->addValidator(new Zend_Validate_File_Size('200MB'))
     ->setAttrib('enctype','multipart/form-data')
     ;
    

I just wanna get only paths of files, don't want to upload file.

Upvotes: 1

Views: 386

Answers (2)

Jay Bhatt
Jay Bhatt

Reputation: 5651

The path your referring to is the path to which the file is uploaded on your server. So you need to first upload the files to a specific folder (i.e. upload) on your server. And then get the path of the file.

I.e.

$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(APPLICATION_PATH.'/temp/upload');

if($adapter->receive()){
    $fileInfo = $adapter->getFileInfo();
    $filePath = APPLICATION_PATH.'/temp/upload/'.$fileInfo['uploadedFile']['name']
}

Upvotes: 0

Jay Bhatt
Jay Bhatt

Reputation: 5651

You can use the HTML5 multiple attribute to select multiple files.

<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <form>
        <input type="file" multiple />
        </form>
    </body>
</html>

You can get the path using javascript....

Upvotes: 1

Related Questions