With a form and the following input tag:
<input type="file" name="images" multiple="" class="inputFileHidden">
I can get the file images on my server just by simply searching through the request.files
object:
images = request.files.getlist('images')
// returns list of imgs.
In my case, I'm not working with a form, but rather I post it using AJAX.
With simple things like text
I can easily post it as such:
Client side
const i_post_title = document.getElementsByName('post_title')[0];
....
$.post('/_upload_post', {
title_post: i_post_title.value
}).done(function(data){
console.log(data)
}).fail(function(){
console.log('fail')
})
And receive it on my server by accessing the request.form
object and passing in the key of the payload sent from the client:
Server Side
title_post = request.form['title_post']
But with files, how should I handle it without having a form?