我需要 POST 一个大约 3mb 的巨大字符串,是否可以不使用 url 参数将其发送到 php?
如果我在 url 参数中发送它,则请求将达到 url 中的大小限制。
如何解决这个问题?有什么线索吗?
非常感谢。
实际上我是这样做的:
$.ajax({
type:'POST',
.......
data:{string:3MB_string}
});
我正在使用 PHP 和 jQuery,我想通过一个简单的 url 将 3mb base64 字符串发送到 php,例如 site.com/script.php
该字符串是文件读取器 API base64 图像
这是一个字符串示例,但这不会达到大小限制,它不是 3mb,因此在粘贴该字符串以显示 3mb 时会遇到麻烦,http://jsfiddle.net/QSyMc/
最佳答案
您将需要使用 POST 请求:
$.ajax({
url: '/script.php',
type: 'POST',
data: { value: 'some huge string here' },
success: function(result) {
alert('the request was successfully sent to the server');
}
});
并在服务器端脚本中检索值:
$_POST["value"]
此外,您可能需要增加允许的请求大小。例如,在您的 .htaccess
文件或 php.ini
中,您可以设置 post_max_size
值:
#set max post size
php_value post_max_size 20M
关于javascript - Jquery Ajax - 发布巨大的字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17810063/