Skip to content

Work with Laravel  #15

@hugomosh

Description

@hugomosh

This is a nasty code but It work for me for an AngularJs and Laravel 5 integration. I am just happy and want to share it for sme. It is a copy from one post here but modified.

    public function getSubirArchivo($declaracion) {
        error_log('Documento 22');

        $request = new \Flow\Request();
        $config = new \Flow\Config(array(
            'tempDir' => './chunks_temp', //With write access
        ));

        $file = new \Flow\File($config, $request);
        $response = Response::make('', 200);

        $destination = './archivos/' . $declaracion . '_' . $request->getFileName();
        if ($_SERVER['REQUEST_METHOD'] === 'GET') {
            error_log('Documento GET');
            if (!$file->checkChunk()) {
                error_log('Documento GET2');
                return Response::make('', 204);
            }
        } else {
            if ($file->validateChunk()) {
                $file->saveChunk();
                error_log('Documento VaLido !!!');

            } else {
                error_log('Documento INVALIDO');
                // error, invalid chunk upload request, retry
                return Response::make('Error in chunck', 400);
            }
        }
        if ($file->validateFile() && $file->save($destination)) {
            error_log('EXITO!');
            $response = Response::make('pass some success message to flow.js', 200);
        }
        return $response;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions