Skip to content

In php, form data is available only in POST method. This OctoberCMS plugin makes them available in other methods like PUT and PATCH

License

Notifications You must be signed in to change notification settings

meysammahfouzi/put-form-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

There is a bug in php which has been described here:

Data that is posted to PHP via the PUT method is not parsed at all and is not available to PHP. This is particularly problematic for data sent encoded as 'multipart/form-data'.

Basically, a request sent (with files and/or non-file data) via PUT should be parsed using the same functions used for requests sent via POST.

This is an OctoberCMS plugin which fixes this problem.

The Problem

Suppose you are calling a REST API which accepts two parameters: title and photo.
This API must be called via PUT method to update a resource.
In your javascript code, you encode the title and photo as multipart/form-data and send the PUT request.
On the server side though, because of the above PHP bug, trying to access the uploaded file or accessing the title field will fail. In other words, all of the following will either return false or null:

  • Input::has('title')
  • Input::get('title')
  • Input::hasFile('photo')
  • Input::file('photo')

Solution

By simply installing this plugin, the form-data become available in your PUT and PATCH requests exactly as they appear in POST requests.

About

In php, form data is available only in POST method. This OctoberCMS plugin makes them available in other methods like PUT and PATCH

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages