< iframe src如何读取本地临时文件? [英] How <iframe src can read local temp file?

查看:73
本文介绍了< iframe src如何读取本地临时文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我如何将文件保存在Web服务器文件夹而不是本地客户端的文件夹中?或者如何将文件从本地客户端的文件夹移动到Web服务器的文件夹?


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 ?

我的问题是,我想使用src在本地读取文件,并且您知道src仅用于Web服务器的文件.

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.

这是我的代码.aspx:

Here is my code .aspx:

<IFRAME id=iframePDF style="WIDTH: 720px; HEIGHT: 700px" runat="server"></IFRAME>  

这是代码隐藏的:

    sFilePath = System.IO.Path.GetTempFileName() 
    System.IO.File.Move(sFilePath, System.IO.Path.ChangeExtension(sFilePath, ".pdf"))
    sFilePath = System.IO.Path.ChangeExtension(sFilePath, ".pdf")
    System.IO.File.WriteAllBytes(sFilePath, buffer)
    iframePDF.Attributes.Add("src", sFilePath)

问题是:
sFilePath是本地路径,而src无法读取本地路径吗?

The problem is:
sFilePath is a local path , and src can not read local path ?

感谢您的帮助

艾哈迈德.

推荐答案

您不能直接与客户端的文件系统进行交互.
期间.

You cannot directly interact with the client's filesystem.
Period.

 

相反,您应该创建一个ASHX处理程序,将PDF发送给客户端,然后将 src 指向该ASHX.
您可以使用查询字符串将信息传递给ASHX处理程序.

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.

这篇关于&lt; iframe src如何读取本地临时文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆