In this task, we will be creating a new document upload form; file uploads will be stored in the filesystem, and the information regarding the file upload will be stored in the database in a table named uploads
. The file uploads are stored in a folder location defined in the module configuration. Perform the following steps to do so:
Our first step will be to define a location where files can be uploaded in the module's configuration (
config/module.config.php
):<?php return array( // Other configurations // .. // .. // MODULE CONFIGURATIONS 'module_config' => array( 'upload_location' => __DIR__ . '/../data/uploads', ), );
Next, we need to create a table which will store the upload information:
CREATE TABLE IF NOT EXISTS uploads ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , filename VARCHAR( 255 ) NOT NULL , label VARCHAR( 255 ) NOT NULL , user_id INT NOT NULL, UNIQUE KEY (filename) );