I've been trying to create a simple single file upload. But I keep getting the error 'A server error occurred while uploading the file'
My js file contains the following code where the table name is called 'deenk_files' and the primary key of the table is file_id
{
label: "Image:",
name: "image",
type: "upload",
display: function ( file_id ) {
return '<img src="'+editor.file( 'deenk_files', file_id ).web_path+'"/>';
},
clearText: "Clear",
noImageText: 'No image'
}
My php file contains the following code.
Field::inst( 'image' )
->setFormatter( Format::ifEmpty( null ) )
->upload( Upload::inst( 'D:\data/test.png' )
->db( 'deenk_files', 'file_id', array(
'filename' => Upload::DB_FILE_NAME,
'filesize' => Upload::DB_FILE_SIZE,
'web_path' => Upload::DB_WEB_PATH,
'system_path' => Upload::DB_SYSTEM_PATH
) )
)
Any idea what is going wrong here?