Skip to content

Not storing filename #3

Description

@larry-tx

I'm having a problem with getting the plugin to store the filename in the database. It uploads the file just fine, but never saves the filename. My table looks like this:

CREATE TABLE crochet_items_files (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
crochet_item_id int(11) NOT NULL,
title varchar(255) NOT NULL,
filename varchar(255) NOT NULL,
mimetype varchar(255) DEFAULT NULL,
filesize int(11) DEFAULT NULL,
created datetime DEFAULT NULL,
modified datetime DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

and my model actsAs statement looks like this:

var $actsAs = array(
    'FileUpload.FileUpload' => array(
        'uploadDir' => 'uploads/crochet_item/files',
        'fileVar' => 'filename',
        'allowedTypes' => array(
            'jpg' => array('image/jpeg', 'image/pjpeg'),
            'jpeg' => array('image/jpeg', 'image/pjpeg'),
            'gif' => array('image/gif'),
            'png' => array('image/png'),
            'txt' => array('text/plain'),
            'pdf' => array('application/pdf'),
            'doc' => array('application/msword')
        ),
        'fields' => array('name' => 'filename', 'type' => 'mimetype', 'size' => 'filesize'),
        'required' => false,
        'unique' => true,
        'fileNameFunction' => false
    )
);

By the way, will FileUpload also save the directory path? I didn't see that among the options.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions