ํ์ผ ์
๋ก๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
<script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.js"></script>
ํ์ผ ์
๋ก๋ scripts
$(document).ready(function () {
bsCustomFileInput.init()
listing()
})
AJax
/* POST ์์ฒญ ajax ์ฝ๋ */
function post_posting() {
// ๊ณ ์ id let ํจ์๋ก ์ ์
let picture = $('#post_picture').val()
let comment = $('#post_comment').val()
let pic = $('#pic')[0].files[0]
let form_data = new FormData()
form_data.append("picture_give", picture)
form_data.append("pic_give", pic)
form_data.append("comment_give", comment)
$.ajax({
type: "POST",
url: "/posting",
// data: {sample_give: let ๋ณ์},
// data: {picture_give:picture, comment_give:comment},
data: form_data,
contentType: false,
processData: false,
success: function (response) {
alert(response['msg'])
window.location.reload()
}
})
}
ํ์ผ ์
๋ก๋ ํผ
<!-- ์ฌ์ง ์
๋ก๋ ํผ -->
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
์ํ๋ ๋ ์ง ์๊ฐ ํํ๋ก ์ถ๋ ฅํ๊ธฐ
from datetime import datetime
now = datetime.now()
print(now)
date_time = now.strftime("%Y-%m-%d-%H-%M-%S")
print(date_time)
# 2022-05-05 19:25:48.610173
# 2022-05-05-19-25-48