New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uploaded file to PHP FPM server is still base64 encoded #64
Comments
I used tcpflow to debug the connection to FPM. It's not doing anything special. The POSTed file is base64 encoded properly.
|
* Removes base64 encoding for contents of files to transfer * Removes Content-Transfer-Encoding: base64 header * Improves determination of file's mime type via mime_content_type(), if available * Adds tests for multipart transfer of files with binary content (images)
@ZizzyZizzy Thank you for your patience! I had a look into this and sadly have to confirm that this is an implementation issue in the library. The "problem" is that PHP-FPM doesn't handle the given After some research and testing I figured that the whole encoding stuff is not necessary at all and the contents of files can be sent as is, no matter what encoding or format. The solutions was to remove the I added tests with an image to verify that the server stores the same file as uploaded. The fixed version is already pushed to development branch. I'll release it as |
@hollodotme This is great news! I will test it out in the next day or so, but it sounds like this will fix the issue! It will actually be nice not to have to deal with the 30%+ size inflation of uploads, or attempt to Base64 decode with PHP and watch it crash out of memory for very large uploads! |
@hollodotme It works perfectly, thank you! |
Expected Behavior
When a file is uploaded, it should be decoded automatically.
Actual Behavior
File is still base64 encoded
Steps to Reproduce the Problem
Use fast-cgi-client to upload a file to a native PHP 7.2 FPM server. (I'm using Ubuntu)
Save the uploaded file and notice it's still base64 encoded
Specifications
fast-cgi-client Build 9b392b0
`> # uname -a
Further comments
I honestly can't yet tell if this is an issue with the way fast-cgi-client is sending the file, or if it's something strange with PHP FPM on the server side.
Here's the file I'm sending:
My debugging shows the inflated size of the file and the wrong mime type on the FPM server side:
When I use move_uploaded_file to /var/tmp/, it's clear that the image file is base-64 encoded. Decoded with "base64 -di", it is exactly the same file and size that I uploaded.
I've spent the better part of an hour checking php.ini, www.conf, and everywhere else I can think of to try and figure out why FPM is not decoding the image.
The code I'm using to send the image file is nearly identical to the one under the examples that comes with the source code. I'm just passing the path to the image file. Here's the debug output right before it sends $postdata and $files:
Here's a snippet of the code I'm using to send.
The text was updated successfully, but these errors were encountered: