Last active
January 20, 2020 11:51
-
-
Save findsomeoneyys/5d58982f4446fdf2bb692ebe9fda72b4 to your computer and use it in GitHub Desktop.
odoo multifile upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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 | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ruter