【发布时间】:2010-09-05 21:26:58
【问题描述】:
我的网站在根目录下,即/www.lebmotor.com/web/content/。
我正在使用这个:
Dim appPath As String = HttpContext.Current.Request.ApplicationPath
Dim directory As String = appPath & "/upload/" & Left(TableName, 2) & "/"
获取路径并且它工作得很好。
但是当我创建一个新的子文件夹并将一些页面从根目录复制到子文件夹时,由于路径已更改,我的图像不显示。
这是来自根目录页面的链接:
http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM
这是子文件夹中页面的链接:
http://www.lebmotor.com/ar/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM
那么我怎样才能像这样在子文件夹中创建链接:
http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM
让我详细解释一下。首先,我有两个目录,它们都被设置为应用程序目录,如图所示:
/ar 子文件夹是一个应用程序,它是 Content 目录中原始应用程序的副本。
在ar/App_code 中有一个名为MGImages.vp 的类,当然它是Content/App_code 中原始类的副本。这个类的工作是显示来自Upload 子文件夹的照片。
这是保存照片路径的代码:
Dim appPath As String = HttpContext.Current.Request.ApplicationPath
Dim directory As String = appPath & "/upload/" & Left(TableName, 2) & "/"
If ImageType.ToUpper = "TN" Then
directory += "TN/"
ElseIf ImageType.ToUpper = "LG" Then
directory += "LG/"
Else
directory += "OT/"
End If
此类在Content 目录中运行良好,因为这将为我提供正确的路径:
http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM
所有照片都应保存在两个目录的Content/arContent/Upload 文件夹中
但是在ar 目录中它会给我错误的路径:
http://www.lebmotor.com/ar/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM
目标是使路径像这样:
http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM
我希望它显示来自Content/upload 的照片,而不是来自content/ar/upload 的照片。
【问题讨论】: