admin管理员组文章数量:1391964
I try to pass a png image from JavaScript to PHP page by pressing a button. But it returns me an error stating "Request-URI Too Large". Below is my codes:
myJavaScript.js
var w = window.open();
var dom = w.document;
var a = canvas[0].toDataURL("image/png");
dom.write('< input type="button" value="Submit" onclick="location.href=\'result.php?a=' + a + '\'" ></input>');
result.php
<?php
$aImg= $_GET["a"];
$to = "[email protected]";
$subject = "Sending an image to email";
$body = '<img src="' .$aImg. '" alt="This is an image" />';
if (mail($to, $subject, $body))
{
echo("Message successfully sent!");
}
else {
echo("Message delivery failed...");
}
?>
However, it returns "The requested URL's length exceeds the capacity limit for this server."
I try to pass a png image from JavaScript to PHP page by pressing a button. But it returns me an error stating "Request-URI Too Large". Below is my codes:
myJavaScript.js
var w = window.open();
var dom = w.document;
var a = canvas[0].toDataURL("image/png");
dom.write('< input type="button" value="Submit" onclick="location.href=\'result.php?a=' + a + '\'" ></input>');
result.php
<?php
$aImg= $_GET["a"];
$to = "[email protected]";
$subject = "Sending an image to email";
$body = '<img src="' .$aImg. '" alt="This is an image" />';
if (mail($to, $subject, $body))
{
echo("Message successfully sent!");
}
else {
echo("Message delivery failed...");
}
?>
However, it returns "The requested URL's length exceeds the capacity limit for this server."
Share Improve this question asked Jun 25, 2012 at 5:57 user1407415user1407415 1091 silver badge8 bronze badges 02 Answers
Reset to default 8Use post instead.
dom.write('<form method="post" action="result.php"><input type="a" value="'+a+'" /><input type="submit" value="Submit" /></form>')
Because passing variables using the GET method require putting the variables in the URL, you will hit the maximum length of a URL for large variables. POST does not have a limit, or at least has a much larger one.
Change to use POST
instead of GET
, if you use GET
, the URL length limit be exceeded for big data.
本文标签: Pass png image from JavaScript to PHP (Error RequestURI Too Large)Stack Overflow
版权声明:本文标题:Pass png image from JavaScript to PHP (Error: Request-URI Too Large) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744673413a2618964.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论