从网站保存图像并从其他网站访问它

时间:2022-11-11 23:07:16

I have created a website let's name it a.com. Now in this website (a.com) the users can upload an image that gets saved to a folder on remote server and the path is getting saved to database.

我创建了一个网站,我们将其命名为a.com。现在,在这个网站(a.com)中,用户可以上传保存到远程服务器上的文件夹的图像,并将路径保存到数据库。

There is a second website (b.com) which has been hosted on the same server where the image needs to be retrieved.

还有第二个网站(b.com)托管在需要检索图像的同一台服务器上。

Can we do this? If yes then please suggest some solution

我们可以这样做吗?如果是,那么请提出一些解决方案

Language Used = Asp.net 4.0 C# Backend = SQL2008

使用的语言= Asp.net 4.0 C#Backend = SQL2008

3 个解决方案

#1


0  

It cane be done, if both website can access the remote folder. You need to use something like System.Net.WebClient to download image from remote server.

如果两个网站都可以访问远程文件夹,那就完成了。您需要使用类似System.Net.WebClient的东西从远程服务器下载图像。

#2


0  

Since your using SQL and .Net im going to assume your using IIS aswell,

既然你使用SQL和.Net我会假设你使用IIS,

Creating a Virtual directory is probably your best bet, Easy to setup, easy to manage and Extremely handy to understand (if not vital)

创建一个虚拟目录可能是你最好的选择,易于设置,易于管理和非常方便理解(如果不是至关重要的)

http://www.iis.net/learn/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis

This is assuming you want to display the image in b.com, if you simply want to retrieve it you can do so by retrieving the path and using the image in any other way, you may need to set permissions on the image folder.

这假设您要在b.com中显示图像,如果您只是想要检索它,您可以通过检索路径并以任何其他方式使用图像来执行此操作,您可能需要在图像文件夹上设置权限。

#3


0  

first of all both sites should use the same database to share information about images. If I understand correctly b.com and the files are on the same server. If so put folder's virtual path to configuration. After that, check database for new records. If found one, parse the name of the file and find it on the server.

首先,两个站点都应使用相同的数据库来共享有关图像的信息。如果我理解正确的b.com和文件在同一台服务器上。如果是这样,将文件夹的虚拟路径放到配置中。之后,检查数据库以获取新记录。如果找到一个,解析文件的名称并在服务器上找到它。

As an example you get an image on a.com and insert it on database as

例如,您在a.com上获取图像并将其插入数据库中

name="image.jpg"

b.com checks database for new records and finds image.jpg. b.com reads configuration and finds

b.com检查数据库是否有新记录,并找到image.jpg。 b.com读取配置并查找

path="http://c.com/"

combines path and imagename

结合路径和图像名称

fulllink="http://c.com/image.jpg"

#1


0  

It cane be done, if both website can access the remote folder. You need to use something like System.Net.WebClient to download image from remote server.

如果两个网站都可以访问远程文件夹,那就完成了。您需要使用类似System.Net.WebClient的东西从远程服务器下载图像。

#2


0  

Since your using SQL and .Net im going to assume your using IIS aswell,

既然你使用SQL和.Net我会假设你使用IIS,

Creating a Virtual directory is probably your best bet, Easy to setup, easy to manage and Extremely handy to understand (if not vital)

创建一个虚拟目录可能是你最好的选择,易于设置,易于管理和非常方便理解(如果不是至关重要的)

http://www.iis.net/learn/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis

This is assuming you want to display the image in b.com, if you simply want to retrieve it you can do so by retrieving the path and using the image in any other way, you may need to set permissions on the image folder.

这假设您要在b.com中显示图像,如果您只是想要检索它,您可以通过检索路径并以任何其他方式使用图像来执行此操作,您可能需要在图像文件夹上设置权限。

#3


0  

first of all both sites should use the same database to share information about images. If I understand correctly b.com and the files are on the same server. If so put folder's virtual path to configuration. After that, check database for new records. If found one, parse the name of the file and find it on the server.

首先,两个站点都应使用相同的数据库来共享有关图像的信息。如果我理解正确的b.com和文件在同一台服务器上。如果是这样,将文件夹的虚拟路径放到配置中。之后,检查数据库以获取新记录。如果找到一个,解析文件的名称并在服务器上找到它。

As an example you get an image on a.com and insert it on database as

例如,您在a.com上获取图像并将其插入数据库中

name="image.jpg"

b.com checks database for new records and finds image.jpg. b.com reads configuration and finds

b.com检查数据库是否有新记录,并找到image.jpg。 b.com读取配置并查找

path="http://c.com/"

combines path and imagename

结合路径和图像名称

fulllink="http://c.com/image.jpg"