Played around with this for a bit of fun, im thinking about using it to upload avatars, torrent images and stop files been uploaded to the server, this code uploads to imgbb then returns the link - so far ive just done the test page
You need to make account and get key here https://api.imgbb.com/
Then create a file imgbb.php and place in it (remember to add your key)
[ATTACH type="full" alt="5388"]5388[/ATTACH]
You need to make account and get key here https://api.imgbb.com/
Then create a file imgbb.php and place in it (remember to add your key)
<?php
require_once("backend/functions.php");
dbconn();
loggedinonly();
stdhead();
begin_frame();
function save_record_image($image,$name = null){
$API_KEY = 'YOUR_CLIENT_API_KEY'; // ADD YOUR KEY
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.imgbb.com/1/upload?key='.$API_KEY);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
$file_name = ($image['name']) ;
$data = array('image' => base64_encode(file_get_contents($image['tmp_name'])));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
if (curl_errno($ch)) {
return 'Error:' . curl_error($ch);
}else{
return json_decode($result, true);
}
curl_close($ch);
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="record_image" accept="image/*">
<button type="submit">Upload</button>
</form>
<?php
if (!empty($_FILES['record_image'])) {
$return = save_record_image($_FILES['record_image']);
echo $return['data']['url'];
}
end_frame();
stdfoot();[ATTACH type="full" alt="5388"]5388[/ATTACH]

