Skip to content

Instantly share code, notes, and snippets.

@findsomeoneyys
Last active January 20, 2020 11:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save findsomeoneyys/5d58982f4446fdf2bb692ebe9fda72b4 to your computer and use it in GitHub Desktop.
Save findsomeoneyys/5d58982f4446fdf2bb692ebe9fda72b4 to your computer and use it in GitHub Desktop.
odoo multifile upload
class MainController(http.Controller):
@http.route('/photo_upload', type='http', csrf=False, auth='user')
def photo_update(self, **kwargs):
Ira = request.env['ir.attachment'].sudo()
//img1
image_buffer_random = kwargs['avatar'].stream.read()
image = base64.b64encode(image_buffer_random)
//img2
image_buffer_random2 = kwargs['avatar2'].stream.read()
image = base64.b64encode(image_buffer_random2)
$('button').click(function(){
var files = $('#avatar').prop('files');
var data = new FormData();
data.append('avatar', files[0]);
data.append('avatar2', files[0]);
$.ajax({
url: '/api/upload',
type: 'POST',
data: data,
cache: false,
processData: false,
contentType: false
});
});
@findsomeoneyys
Copy link
Author

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