๐Ÿ’ป ๊ณต๋ถ€ ๊ธฐ๋ก/๐ŸŽž๏ธ JavaScript

Ajax/JQuery | ์‚ฌ์ง„ ์—…๋กœ๋“œ

  • -

ํŒŒ์ผ ์—…๋กœ๋“œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

<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
 
 
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.