Javascript/Basic

[JavaScript] imgbb 이미지 업로드 api Post 코드

yoonjong Park 2023. 1. 6.

무료 이미지 서버 사용하는 방법이다.

 <button
        onClick={() => {
          var formData = new FormData();
          formData.append(
            "image",
            "iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAIAAACzY+a1AAAS/0lEQVR42u2deZQURZrAvy8iK6u6jj7og26wAWU4BhRlcFaBGcEFVsUn6qK+dRyP8VhnnFFxZzxGdx10jh2YnTfKk6fjG1cdkXVYVx3FGwVRPBAB8UQUlYa+6Luquo7MiG//iKrqBqu7svpOXvxe0+81XZ0ZGb+MyIjIiC8w9uU40LgZNtwJ0PQXrdD1aIWuRyt0PVqh69EKXY9W6Hq0QtejFboerdD1aIWuRyt0PVqh69EKXY9W6Hq0QtejFboerdD1aIWuRyt0PVqh69EKXY9W6Hq0QtejFboerdD1aIWuRyt0PVqh69EKXY9W6Hq0QtejFboerdD1aIWuRyt0PVqh69EKXY9W6Hq0QtejFboerdD1aIWuRyt0PVqh69EKXY9W6Hq0QtejFboerdD1aIWuRyt0PVqh69EKXY9W6Hq0QtejFboerdD1aIWuRyt0PVqh69EKXY9W6Hq0QtdjDHcCjigo9a8LxEE/6ZGjkPL5MBLAQGQuESACERFB6it9YJUeBEAExgAAEVOfH1iOBIWpfCEi6UCM+jBDIsK+ZmfGnBCACD4vch+SgUhAgkACECAD4AAMCQAtsmMUTxIAcA6IOIAujwSFAASAcQvao+QkX0wDRoWQ8iq2mTMRISIRSQH+EEMvNtTaL22Jb9ma2PVRcl+taGkWlkUEwBkW+HF0Oa8ea8w8zpx9ovekE8yiMi5j1BmVjANCv26jDHgEbMdMRAU+tnpt+Ge/aFGVVe8smud76anKaLPgPI/sU+VGEpGAwCje2iIeWBv5y5rI7j1W948hposXgfxGSmbNNH98aeiipQGfF6NtkhsAgID9qtSPnBaphyMAGAZw3tsXAORlTkFEiGDb5POzOMDl1zWVTq658Vetu/dYnKtHXeaTICVIeYg/9TjkHN7bkbxqWXPxxH23r2gz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E0eIkcuRHyMxtvdG0zrvIl8zhUa1BUOzOTI0M4mJJJIeddkghAQrcnNkMOXb8djESOXIXd6eWeHcoBMCcpxF5/OxiMiEmImv6gFboerdD1aIWuRyt0PVqh69EKXY9W6Hr+HxnIYeh4LOgEAAAAAElFTkSuQmCC"
          ); //base-64 그대로 업로드
          formData.append("key", "037ba0c7f32f842a90854ff9792a0a8b");

          console.log(
            axios({
              method: "post",
              url: "https://api.imgbb.com/1/upload",
              data: formData,
              headers: {
                "content-type": "multipart/form-data",
              },
            })
          );
        }}>
        이미지 호출
      </button>

 

참고

https://api.imgbb.com/

 

Upload Image — Free Image Hosting

Free image hosting and sharing service, upload pictures, photo host. Offers integration solutions for uploading images to forums.

api.imgbb.com

https://imgbb.com/

 

무료 이미지 호스팅 / 이미지 업로드

이미지를 업로드 하고공유해보세요. 원하는 곳 어디든 끌어놓기로 이미지를 바로 업로드해보세요.(이미지당 32 MB 가능) 다이렉트 링크, BBCode 및 HTML 미리보기등을 제공해드립니다.

imgbb.com

 

댓글