uploading multiple files using Zend framework file component with example

24 Nov

Some developer may find it hard to upload several files using Zend Framework file component. In some cases developers may provide more than one file fields, say five(5) and when user tries to upload three files, so instead of uploading those three files, his files are simply ignored from being uploaded.
This is because Zend Framework uses receive function which first check all the file fields. If any of them is empty or unvalid, Zend Framwork file receive() function stop execution and none of the file uploaded.
A simple solution to this problem is to take file names of each file element and pass it to the receive function like
Note that receive function take a path to the file in form of string.
Consider you have the following file fields in your form
file1,file2,$file3 etc.
so in your controller/action


And so on, the above code will give you paths of each file field. Now


So these three files will be uploaded to the specified directory.


3 Responses to “uploading multiple files using Zend framework file component with example”

  1. Faheem Abbas November 27, 2008 at 5:16 am #

    This code is not tested, so it may not work as you want.
    Plsease visit https://zendguru.wordpress.com/2008/11/26/uploading-multiple-files-using-zend-framework-revised/. Revised is tested and working fine.

  2. Partha Sarathi Ghosh November 27, 2008 at 10:49 am #

    How do I change the uploaded file name?

  3. Talib Aziz October 2, 2009 at 11:37 am #

    hello sir
    I am working as developer and using zend framework,
    i have read your article about uploading multiple file, but here is problem you have defined the number of file.
    I want to use only single file element to upload multiple file and all the files should be displayed besides the element with path what i have selected to upload and after that when i clicked submit button all the file should be uploaded.

    please answer me as soon as possible

    Talib Aziz
    New Delhi.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: