关于调用本地的应用程序打开服务器上问题
我想问一下,我现在也实现了图片的上传,保存的目录在网站根目录下的image文件下,我的数据库中存的是图片的名称而不是路径,通过datalist控件显示在网页上,其中datalist里面加了一个imagebutton的控件,这样可以显示多个图片的信息,我现在需要实现的效果是点击图片是调用自己本地的应用程序来打开,比如说mp3就调用mediaplayer播放,这些都是系统默认的,我在自己机器上已经实现了这样的效果,但是上传到服务器上就有问题,也不知道是不是路径的问题。
比如说我的域名为www.dad.com.cn,我怎么写这个路径,请高手指点。
在本地实现的代码如下:
前台:
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" Width="802px" OnItemCommand="DataList1_ItemCommand" RepeatColumns="9">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandArgument='<%#Eval("Path") %>'
CommandName="Open" Height="50px" imageurl='<%#"~\\Image1\\"+Eval("Path") %>' Width="50px" />
<br />
<asp:Label ID="lblImageName" runat="server" Font-Size="11pt" Text='<%# (Eval("Path").ToString()).Substring(Eval("Path").ToString().LastIndexOf("\\") + 1) %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
后台:如上,前台的eval("path")显示的是数据库中存储的图片名(比如001.jpg)
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "Open")
{
string file = Server.MapPath("~/") + "\\Image\\" + e.CommandArgument.ToString();
try
{
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
Info.FileName = file;
System.Diagnostics.Process.Start(Info);//这是调用本地默认的应用程序
}
catch (Exception ex)
{
throw new Exception(ex.Message);
//MessageBox.Show("无法打开该文件,因为" + ex.Message);
}
}
}
在本地可以点击图片就调用应用程序打开。,上传到服务器就不行了。