1. Go to this page and download the library: Download recca0120/upload library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Illuminate\Http\JsonResponse;
use Illuminate\Http\UploadedFile;
use Recca0120\Upload\UploadManager;
class UploadController extends Controller
{
public function upload(UploadManager $manager)
{
$driver = 'plupload'; // or 'fileapi'
$inputName = 'file'; // $_FILES index;
return $manager->driver($driver)->receive($inputName);
// or
return $manager
->driver($driver)
->receive($inputName, function (UploadedFile $uploadedFile, $path, $domain, $api) {
$filename = $uploadedFile->getBasename();
return new JsonResponse([
'name' => $uploadedFile->getClientOriginalName(),
'tmp_name' => $path.$filename,
'type' => $uploadedFile->getMimeType(),
'size' => $uploadedFile->getSize(),
'url' => $domain.$path.$filename,
]);
});
}
}
use Recca0120\Upload\Receiver;
use Illuminate\Http\JsonResponse;
path_to_storage',
'domain' => 'http://app.dev/',
'path' => 'web_path'
];
Receiver::factory($config, 'fileapi')->receive('file')->send();
use Recca0120\Upload\Drivers\FileAPI;
use Recca0120\Upload\Receiver;
to_storage',
'domain' => 'http://app.dev/',
'path' => 'web_path'
];
// if use Plupload, new Recca0120\Upload\Plupload
$receiver = new Receiver(new FileAPI($config));
// save to $config['storage'];
$receiver->receive('file')->send();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.