從網站保存圖像並從其他網站訪問它

[英]Saving images from a website and accessing it from another website


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"

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/11/09/720ca194a48395c1d6fc4bfe388fcdf.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com