Download the PHP package djiele/multipart without Composer
On this page you can find all versions of the php package djiele/multipart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package multipart
multipart-handler
- [ ] This class became necessary during the development of a REST API and had no access to server config and install the "apfd" extension (Linux module) (Windows) . This class parses HTTP multipart/form-data request bodies and try to populate
$_FILES
and$_POST
as PHP would do. The idea was to be able to handle very big files with no memory overflow. Thephp://input
stream is read in chunks of 8192 bytes that are written directly to disk, so very small memory footprint.
At this time there is no check on 'post_max_size
', 'upload_max_filesize
', 'max_file_uploads
' and 'max_input_vars
'. Maybe in a future release this checks will be done to be compliant with server configuration.
Installation
You can install the package via composer:
Simple usage
Using the package with frameworks
just instanciate the class at the very beginning of the framework boot. You have to make sure that the class object will be destroyed at the very end of script or application. Otherwise the uploaded files will be deleted by the destructor before your script can process them. For frameworks like Laravel or Symfony i usually instanciate the handler as a public member of 'app' and 'kernel' respectively.
Sample code for Laravel
in public/index.php, just after the app is created you can add this little code:
At this step the $_POST
and $_FILES
super globals are a populated as would PHP with regular POST method. The framework can then populate the Request->files collection and gives you the ability to use UploadedFile objects as you would do normally. Note that you can not use the 'move' method since it make use of the 'move_uploaded_file' native function of PHP which checks that files where uploaded during POST request. You can to use UploadedFile::store() or UploadedFile::storeAs() and then delete the temporary file.
Sample code for symfony
in the file public/index.php just after the kernel is created add the same little code:
Same remarks and notices as Laravel
Et voilà!