Skip to content

Instantly share code, notes, and snippets.

@AlexR1712
Created September 1, 2016 03:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexR1712/3b5eb2e5816c0c6dd8f3c04ba07bc778 to your computer and use it in GitHub Desktop.
Save AlexR1712/3b5eb2e5816c0c6dd8f3c04ba07bc778 to your computer and use it in GitHub Desktop.
File.io PHP File Upload up to 5GB
<?php
// Use composer
// composer require guzzlehttp/guzzle:~6.0
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'https://file.io', [
'multipart' => [
[
'name' => 'file',
'contents' => fopen('file.png', 'r'),
'filename' => basename('file.png')
],
]
]);
$res = json_decode($response->getBody());
if ($res->success)
{
echo "<h2>File has been uploaded</h2>";
echo "Download <a href='$res->link'>Here</a>";
echo $response->getBody();
}
else
{
echo "Unexpected error";
}
// I'm working on a class for upload and set time expirations and more base on file.io service.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment