Jquery Ajax - 发布巨大的字符串值 [英] Jquery Ajax - post huge string value
问题描述
我需要发布一个大约 3mb 的大字符串,是否可以不使用 url 参数将其发送到 php?
i need to POST a huge string large about 3mb, is it possible to send it to php using not url params?
如果我在 url 参数中发送它,请求就会达到 url 中的大小限制.
If i send it in url params the request reachs the size limit in url.
如何解决这个问题?有什么线索吗?
How can work around this? any clue?
非常感谢.
实际上我是这样做的:
$.ajax({
type:'POST',
.......
data:{string:3MB_string}
});
我正在使用 PHP 和 jQuery,我想通过一个简单的 url 将 3mb base64 字符串发送到 php,例如 site.com/script.php
i'm using PHP and jQuery , and i wouldl ike to send the 3mb base64 string to php on a simple url, like site.com/script.php
该字符串是一个 File Reader API base64 图像
The string is a File Reader API base64 image
这是一个字符串的例子,但它不会达到大小限制,它不是 3mb 不会因为粘贴它以显示 3mb 而引起麻烦,http://jsfiddle.net/QSyMc/
this is an example of string but this won't reach the size limit it is not a 3mb is less cause troubling in pasting that to show you a 3mb, http://jsfiddle.net/QSyMc/
推荐答案
您将需要使用 POST 请求:
You will need to use a POST request:
$.ajax({
url: '/script.php',
type: 'POST',
data: { value: 'some huge string here' },
success: function(result) {
alert('the request was successfully sent to the server');
}
});
并在您的服务器端脚本中检索值:
and in your server side script retrieve the value:
$_POST["value"]
此外,您可能需要增加允许的请求大小.例如,在您的 .htaccess
文件或 php.ini
中,您可以设置 post_max_size
值:
Also you might need to increase the allowed request size. For example in your .htaccess
file or in your php.ini
you could set the post_max_size
value:
#set max post size
php_value post_max_size 20M
这篇关于Jquery Ajax - 发布巨大的字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!