我想通过POST将数据发送到php页面,我需要完全按原样存储字节,但我无法做到。当我发送138个字节时,fput和fwrite返回133。
$fh = fopen($myFile, 'ab') or die("can't open file");
echo fputs($fh, $_POST['data'] ,strlen($_POST['data']));
fclosw
VB.NET:
Dim ar As System.Text.UTF8Encoding = New System.Text.UTF8Encoding
Request.ContentLength = ar.GetByteCount(PostData)
ContentType = "application/x-www-form-urlencoded"
SW = New StreamWriter(Request.GetRequestStream(), ar)
SW.Write(PostData)
-edit 这是加密数据功能
Public Function Encrypt(ByVal stringToEncrypt As String, ByVal key As String) As String
Rijndael.Key = SHA256.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key))
Rijndael.Mode = CipherMode.ECB
Dim Buffer As Byte() = ASCIIEncoding.UTF8.GetBytes(stringToEncrypt)
Return Convert.ToBase64String(Rijndael.CreateEncryptor().TransformFinalBlock(Buffer, 0, Buffer.Length))
End Function
EDITED 例如,原始加密字符串:
j/aokbSUDP1nAD7KafnDoLSmI93sOLiroTwcQIUS/Xw8eUlUZA58OULXCtsnkKqOe+UXlFP6vKuTIWxVMRBZLiBiIOZomNsvoIfM4dv2UzAk2q5mpjo4/0E9lPvu4I7X
发送后
j/aokbSUDP1nAD7KafnDoLSmI93sOLiroTwcQIUS/Xw8eUlUZA58OULXCtsnkKqOe UXlFP6vKuTIWxVMRBZLiBiIOZomNsvoIfM4dv2UzAk2q5mpjo4/0E9lPvu4I7X
答案 0 :(得分:1)
我没有看到为什么这不起作用的原因:
$connection = fopen($file, 'ab');
fwrite($connection, urldecode($_POST['data']));
fclose($connection);