开发者

How <iframe src can read local temp file?

How I can save file in web server folder's instead of local client's folder ?. Or how I can move a file from local client's folder to web server's folder ?

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"))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜