Created
September 1, 2016 03:04
-
-
Save AlexR1712/3b5eb2e5816c0c6dd8f3c04ba07bc778 to your computer and use it in GitHub Desktop.
File.io PHP File Upload up to 5GB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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