simov / express-admin

MySQL, MariaDB, PostgreSQL, SQLite admin for Node.js
MIT License
1.17k stars 223 forks source link

append http://localhost:3000 before image URL. #95

Closed dpz3579 closed 8 years ago

dpz3579 commented 8 years ago

hi i want to use the image upload that is there in your code. the image upload is working fine perfectly,

but if i want to append the string "http://localhost:3000/upload/" before the file name, what steps needs to be performed.

please help us as it is a bit urgent.

dpz3579 commented 8 years ago

found it had to be written in event.js

create custom.js

{
    "events": {
        "events": "./events.js"
    }
}

and event.js use the code

exports.preSave = function (req, res, args, next) {
        if (args.debug) console.log('preSave');
        debugger;
        var uploadUrl = "http://localhost:3006/upload/";

        if (args.name == 'table_name') {
        record = args.data.view.table_name.records[0].columns;
        record.column_name = uploadUrl+args.data.view.table_name.records[0].columns.column_name;
        }
    next();
}