How to upload an string image with Github API #24722
-
I have an image in a string base64 form, like this one below. and I want to upload it to github and make it appear as a normal image. is this possible??? and if it is, How can I do it??
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi there 👋 Indeed, you can upload files via the API and you can use base64 encoding to upload your content. This thread:
Maybe it will help to Someone: <?php $file_git = "wall.jpg"; $data_git = array( 'sha'=>file_get_contents("sha.txt"), 'message'=>'image', 'content'=> base64_encode($file_git), 'committer'=> array( 'name'=>'Jacob', 'email' => '[email protected]' ) ); $data_string_git = json_encode($data_git); $ch_git = curl_init('https://api.github.com/repos/YOUR_REPO/contents/wall.jpg'); curl_setopt($ch_git, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch_git, CURLOPT_POSTFIELDS, $da… …and that specific post ^ should be very useful for you! Give that thread a once-over and let us know if you have more questions/concerns. |
Beta Was this translation helpful? Give feedback.
-
Image is not getting uploaded. Can anyone help? |
Beta Was this translation helpful? Give feedback.
-
files are getting uploaded but not the images. |
Beta Was this translation helpful? Give feedback.
Hi there 👋
Indeed, you can upload files via the API and you can use base64 encoding to upload your content.
This thread: