Reply to Integrating Upload class into Zend Framework 2 (ZF2)

Integrating Upload class into Zend Framework 2 (ZF2) new!
by Tom Herlihy, 10 years, 2 months ago
You can easily modify the Upload class to make use of it within the ZF2 MVC environment by following these steps:
(1) Rename the 'class.upload_0.32' folder 'Upload'.
(2) Within that folder, rename two php files: (A) rename 'upload.php' to 'upload_script.php'; so that you can (B) rename 'class.upload.php' to 'Upload.php'.
(3) Insert a new PHP file into the folder, with the name ' Module.php'. The contents of this short file appear at the bottom of this Forum entry.
(4) Following ZF2 conventions from here on, place the modified 'Upload' folder in your application's Vendor directory/folder.
(5) To tell your application to look for and load the 'Upload' class, add the following to the module list in the 'config/application.config.php' file found in every ZF2 application: 'Upload,'. Note the comma after the word.
(6) In the 'IndexController' or any other Controller file in which you wish to use the Upload class, add the following at the top of the file after the namespace line: 'use Upload/Upload;'.

That's it. You use the standard PHP scripting for Upload within your Controller actions. Following is the contents of the Module.php file:
namespace Upload;
class Module
{
  public function getAutoloaderConfig()
  {      
    return array(
      'Zend\Loader\StandardAutoloader' => array(
        'namespaces' => array(
          __NAMESPACE__ => __DIR__,
        ),
      ),
    );
  }
}
Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important