我有一些工作的PHP代码,它从一串数据创建一个图像,并想知道如何将其转换为ASP:
$jpg = base64_decode($_POST['imagedata']);
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $jpg;
是否符合以下代码的要求?
var image = Request.Params["imagedata"];
if (string.IsNullOrEmpty(imagedata)) return;
var imageContent = Convert.FromBase64String(image);
Response.ContentType = "image/jpeg";
using (var os = Response.OutputStream)
{
for (int i = 0; i < imageContent.Length; i++)
os.WriteByte(imageContent[i]);
os.Flush();
os.Close();
}
谢谢!