Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
ImgBB Api (Upload Image)
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods in Progress

2020-02-29 12:15:04
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)
<?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]
Untitled.png
Untitled.png
2020-02-29 14:44:06
Thanks you ! cooLL!!(y)
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 8
  • Members: 0
  • Guests online: 8
  • Comments: 3
  • Messages: 1,728