微信小程序上传图片的接口方法

var Me = this;
var files = Me.req.files;
var openid = Me.req.body.openid;
var idcard = Me.req.body.idcard;
var ep = new EventProxy();
var tmpFilePath = ‘’;
var fileid = 0;
var OCRContent;
var templateNo;
var temp_filepath = files.file.path;
var filename = temp_filepath.substring(temp_filepath.lastIndexOf(’\’) + 1, temp_filepath.length);
var employeePath = path.join(__dirname, ‘…/…/web/upload/images’);
var exceldir = employeePath;
var fullPath = ‘’;
var file = new File();

        var now = hcUti.formatDate(new Date(), 'yyyy-MM-dd');
        tmpFilePath = idcard + '/' + now + '/';
        exceldir += '/' + idcard + '/' + now;
        fullPath = File.joinfilePath([exceldir, filename]);
        var result_path='upload/images/'+idcard+'/' +now+'/'+filename;
        file.loadFile(temp_filepath, null, ep.doneLater('loadFile'));
        

        ep.once('loadFile', function (result) {
            if (result) {
                return file.createFile(result, exceldir, fullPath, ep.doneLater('createFile'));
            }
        });

        ep.once('createFile', function (result) {
            if (result) {
                
                 return Me.cb(200,null,result_path);
                // ep.emit('ep_updatefile');
                // ep.emit('ep_ocr');
            }
        });

        ep.fail(function (err) {
            return cbError('50003', Me.cb);
        });

你可能感兴趣的:(微信小程序上传图片的接口方法)