简体   繁体   English

输入字段中的base64字符串被截断

[英]base64 string in input field gets truncated

I am using this file uploader plugin , which uses javascript's FileReader API to read files and put them in input elements as base64 strings. 我正在使用此文件上载器插件 ,该插件使用javascript的FileReader API读取文件并将它们作为base64字符串放入输入元素中。 Those files could be up to 5mb, so the base64 strings could become quite long. 这些文件最大为5mb,因此base64字符串可能会变得很长。

Anyway, at first everything seems to be working correctly: I can select a file and inspect my hidden input's content, and the base64 string is equal to what I can obtain by using the base64 command on my linux machine: base64 file.pdf > file.b64 . 无论如何,起初一切似乎都工作正常:我可以选择一个文件并检查隐藏输入的内容,并且base64字符串等于我在Linux机器上使用base64命令可以获得的字符串: base64 file.pdf > file.b64

The problem is that, when I post the form, the string gets truncated after 524261 characters, missing the last 50000 chars (more or less). 问题是,当我发布表单时,字符串在524261个字符后被截断,缺少最后的50000个字符(或多或少)。 Which means that the file is corrupt. 这意味着文件已损坏。

I have tried changing some php setting (through the .htaccess file), but it's still not working, and honestly I can't figure out what the problem could be... 我尝试过更改某些php设置(通过.htaccess文件),但仍然无法正常工作,老实说,我无法弄清楚问题可能出在哪里...

upload_max_filesize = 10M
post_max_size = 10M

So, the problem was actually chrome (I suppose some other browsers could have the same issue too). 因此,问题实际上是chrome(我想其他一些浏览器也可能有同样的问题)。 I have solved it by using a textarea instead of an input. 我已经解决了通过使用textarea而不是输入。 Since the fileUploader plugin that I was using doesn't support textareas instead of inputs for the file content, I will probably do a pull request with the fix. 由于我使用的fileUploader插件不支持textareas而不是文件内容的输入,因此我可能会使用此修复程序发出请求请求。 Thank you gre_gor for pointing out the browser issue, thank you all for your help. 谢谢gre_gor指出浏览器问题,谢谢大家的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM