我有一个无法解释的问题
我有一个C#程序将图像(截图整个网页的一些网址)编码发送到base64
static string ImageToBase64(System.Drawing.Image image, System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
// image is typeof Bitmap
string myImageData = ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Jpeg);
using (WebClient client = new WebClient())
{
try
{
byte[] response = client.UploadValues("http://production/ws/imageBuilder", new NameValueCollection()
{
{ "myImageData", HttpUtility.UrlEncode(this.myImageData) }
{ "Url_", url.Authority },
{ "token", ImageHash }
});
Debug.WriteLine("Server Said: " + System.Text.Encoding.Default.GetString(response));
byte[] response2 = client.UploadValues("http://localhost/ws/imageBuilder", new NameValueCollection()
{
{ "myImageData", HttpUtility.UrlEncode(this.myImageData) }
{ "Url_", url.Authority },
{ "token", ImageHash }
});
Debug.WriteLine("Server Said: " + System.Text.Encoding.Default.GetString(response2));
}
catch(Exception e) {Debug.WriteLine(e.Message);}
}
在PHP方面,我只是为了测试
echo "length before decode ".strlen($_POST['myImageData']);
$imageData = base64_decode(urldecode($_POST['myImageData']));
echo "length after decode ".strlen($imageData);
返回大图像(例如1280 x 10 000)
[4908] Server Said: length before decode 0 length after decode 0
[4908] Server Said: length before decode 1333258 length after decode 925151
所以在我的本地WAMP服务器上(在Windows 7上)我收到图像但是在生产中(在Linux上)我什么都没收到。
但是"小"例如尺寸" 1280 x 1024"没关系,我的变量$_POST['myImageData']
在生产时不是空的,它运行正常。
[4908] Server Said: length before decode 66292 length after decode 46210
[4908] Server Said: length before decode 66292 length after decode 46210
更新:图片是小JPG(介于200ko和1.5mo之间)。
我的php.in正在制作中
upload_max_filesize = 20M
post_max_size = 18M
生产中的我的Apache是 mod_proxy
答案 0 :(得分:0)
如果我不得不猜测,我会说检查你的" post_max_size" php.ini中的参数。它可能在Linux服务器上设置得比WAMP服务器低。