flowjs / flow-php-server

flow.js php server library, validates uploaded chunks and safely merges all chunks to a single file
http://flowjs.github.io/ng-flow/
MIT License
243 stars 44 forks source link

How to upload file from html post to php using flow-php-sever? #25

Closed ravitejac closed 9 years ago

ravitejac commented 9 years ago

Hi,

I am using this code and filename save it as upload.php as follows: But after submitting the form through html and where to pass uploaded_file (i.e.,) $_FILES['uploaded_file']['tmp_name'] and $_FILES['uploaded_file']['name'] in backend how to use.

require_once 'vendor/autoload.php';

$config = new \Flow\Config(); $config->setTempDir(storage_path() . '/temp'); $destination = 'uploads/'; $file = new File($config); $request = new \Flow\Request();

    if ($_SERVER['REQUEST_METHOD'] === 'GET') {

        if ( ! $file->checkChunk() ) {
            return \Response::make('',204);
        }
    } else {
        if ($file->validateChunk()) {
            $file->saveChunk();
        } else {
            return \Response::make('', 400);
        }
    }
    if ($file->validateFile() && $file->save($destination . $request->getFileName())) {
        return \Response::make('File upload was completed', 200);
    }
AidasK commented 9 years ago

Some links with laravel which might help: https://github.com/flowjs/ng-flow/issues/40#issuecomment-105600893 https://github.com/flowjs/flow-php-server/issues/15 https://github.com/flowjs/flow-php-server/issues/3