getCode() . "|" . $e->getLine() . ": " . $e->getMessage()); } UI::dol(); } public function uploadStreamAction() { Response::sendTryCatchJson(array($this, 'uploadStreamResponseCallback')); } public function uploadStreamResponseCallback() { $response = array(); $response['type'] = 'danger'; $response['msg'] = "Wystąpił nieznany błąd podczas wgrywania pliku"; $sqlLabel = V::get('name', '', $_REQUEST); // read contents from the input stream $inputHandler = fopen('php://input', "r"); $idFile = FileStorage::addFileStream($inputHandler, $sqlLabel); $response['id'] = $idFile; $fileObject = FileStorage::getFileById($idFile); if ($fileObject['exists']) { $response['type'] = 'success'; $response['msg'] = "Wgrano plik nr {$idFile}"; } return $response; } public function uploadAction() { try { $fileContent = Request::getRequestBody(); $sqlLabel = V::get('name', '', $_REQUEST); FileStorage::addFile($fileContent, $sqlLabel); echo 'file uploaded'; } catch (Exception $e) { echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage(); } } public function uploadFromBinaryTestAction() { try { $fileContent = Request::getRequestBody(); $filePath = FileStorage::getRootStoragePath() . '/test-upload-data.txt'; $fp = fopen($filePath, 'w'); fwrite($fp, $fileContent); fclose($fp); echo 'file uploaded?'; } catch (Exception $e) { echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage(); } } public function downloadAction() { try { $id = V::get('id', 0, $_REQUEST, 'int'); if ($id <= 0) throw new Exception("Error Wrong file id"); $fileObject = FileStorage::getFileById($id); if (!$fileObject['exists']) throw new HttpException("File not exists", 404); header('Content-Description: File Transfer'); header('Content-Type: ' . $fileObject['mimeType']); header('Content-Disposition: attachment; filename="' . $fileObject['name'] . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . $fileObject['size']); readfile($fileObject['absolutePath']); exit; } catch (HttpException $e) { Http::sendHeaderByCode($e->getCode()); die($e->getMessage()); } catch (Exception $e) { die("Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage()); } } public function downloadTestAction() { try { $filePath = FileStorage::getRootStoragePath() . '/test-upload-data.txt'; if (!file_exists($filePath)) throw new Exception("file not exists!"); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($filePath).'"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($filePath)); readfile($filePath); exit; } catch (Exception $e) { echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage(); } } public function uploadFromFormTestAction() { try { // $fileContent = Request::getRequestBody(); DBG::_(true, true, '_POST', $_POST, __CLASS__, __FUNCTION__, __LINE__); // $filePath = FileStorage::getRootStoragePath() . '/test-upload-data.txt'; // $fp = fopen($filePath, 'w'); // fwrite($fp, $fileContent); // fclose($fp); // echo 'file uploaded?'; } catch (Exception $e) { echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage(); } } public function uploadFormTestAction() { UI::gora(); UI::menu(); try { // multiple: // only images: ?>
root storage path:
table name:
IP:
';
for ($i = $start; $i < $limit; $i++) {
FileStorage::generateFilePathHashFromId($i);
}
echo '';
} catch (Exception $e) {
echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage();
}
}
public function reinstallAction() {
UI::gora();
UI::menu();
FileStorage::reinstall();
UI::dol();
}
}