PHP code example of tomkirsch / dropzone
1. Go to this page and download the library: Download tomkirsch/dropzone 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/ */
tomkirsch / dropzone example snippets
namespace App\Controllers;
class Uploadfile extends BaseController{
public function chunk(){
$dropzone = service('dropzone');
$movedFile = $dropzone->readChunk('userfile');
return $this->response->setJSON([
'chunk'=>$movedFile,
]);
}
public function assemble(){
$dropzone = service('dropzone');
$path = 'uploads';
if(!is_dir($path)) mkdir($path);
$file = $this->request->getPost('filename');
$filePath = $path.'/'.$file;
if(file_exists($filePath)) unlink($filePath);
$dropzone->assemble($filePath);
return $this->response->setJSON([
'file'=>$filePath,
]);
}
public function clean(){
$dropzone = service('dropzone');
}
}