How <iframe src can read local temp file?
My problem, is that I would like to read a file in local using src , and as you know src only for web server's files.
Here is my code .aspx:
<IFRAME id=iframePDF style="WIDTH: 720px; HEIGHT: 700px" runat="server"></IFRAME>
Here is Code-Behind :
sFilePath = System.IO.Path.GetTempFileName()
System.IO.File.Move(sFilePath, System.IO.Path.ChangeExtension(sFilePath, ".pdf"))
sFilePath = System.I开发者_如何学CO.Path.ChangeExtension(sFilePath, ".pdf")
System.IO.File.WriteAllBytes(sFilePath, buffer)
iframePDF.Attributes.Add("src", sFilePath)
The problem is:
sFilePath is a local path , and src can not read local path ?Thanks for your help,
Ahmed.
You cannot directly interact with the client's filesystem.
Period.
Instead, you should create an ASHX handler that sends the PDF to the client, then point the src
to that ASHX.
You can pass information to the ASHX handler using the querystring.
This is how I solved the problem :
iframePDF1.Attributes.Add("src", "ShowPDF.ashx?pID=" & Request.QueryString("pID"))
精彩评论