jQuery的阿贾克斯 - 后巨大的字符串值 [英] Jquery Ajax - post huge string value
问题描述
我需要发布一个巨大的串大约为3MB,是否有可能将其发送不使用URL PARAMS到PHP?
i need to POST a huge string large about 3mb, is it possible to send it to php using not url params?
如果我在URL PARAMS请求发送的网址reachs的大小限制。
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,和我wouldl艾克派3MB的base64字符串到PHP一个简单的URL,如 site.com/script.php
该字符串是一个文件读取器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的阿贾克斯 - 后巨大的字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!