Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * First: Login and prepare upload
- */
- $login = array(
- // Mandatory
- 'password' => md5('secretpasswort'),
- // Optional parameters:
- 'presentation' => '', // "1 = ONLY ZIP Download | 2 standard downloadside | 3 Image slider"
- 'message' => '', // "Here your files."
- 'zip_code' => '', // "0000, 1111"
- 'sms_number' => '', // "+97100000, +97111111"
- 'file_password' => '', // "secret password"
- 'password_hint' => '', // "password notice / tip"
- );
- // Do Curl Request
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://api.fileload.io/startupload');
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $login);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $query = curl_exec($ch);
- if (curl_errno($ch)) { die('Error: ' . curl_error($ch)); }
- curl_close($ch);
- $response = json_decode($query)[0];
- if (isset($response->error) AND $response->error == 'unknown_user') {
- echo 'Error while login. Email or password wrong!';
- }
- echo '<pre>';
- print_r($response);
- echo '</pre>';
- /**
- * Second: Begin upload...
- */
- // Do Curl Upload
- $ch = curl_init($response->server);
- // Create a CURLFile object; Syntax: public CURLFile::__construct ( string $filename [, string $mimetype [, string $postname ]] )
- $cfile = new CURLFile('50M.zip','application/zip','50M.zip');
- // Assign POST data
- $prepare_transfer = array(
- 'server' => $response->server,
- 'email' => $response->email,
- 'password' => $response->password,
- 'transfer_id' => $response->transfer_id, // OR FIX to upload into same folder ''
- 'file' => $cfile,
- 'chunk' => 0, // Current chunk
- 'chunks' => 0 // Total number of chunks
- );
- // Request a HTTP POST
- curl_setopt($ch, CURLOPT_POST, true);
- // Specify data to POST to server
- curl_setopt($ch, CURLOPT_POSTFIELDS, $prepare_transfer);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- // Execute the handle
- $upload = curl_exec($ch);
- if (curl_errno($ch)) { die('Error: ' . curl_error($ch)); }
- curl_close($ch);
- $file = json_decode($upload)[0];
- #echo $file->url;
- echo '<pre>';
- print_r($file);
- echo '</pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement