FTP链接的用户名和密码 [英] FTP Username and password in html link

查看:511
本文介绍了FTP链接的用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在发布此问题之前通过Google搜索,但我对Google的搜索结果不满意。我希望有人能帮助我。



我有一个电子商务网站。所有的图像都存储在不同的ftp服务器上。我需要在我的网页上显示所有图像。当页面放置时,它要求输入FTP用户名和密码。我可以通过在FTP URL中提供用户名和密码来避免它。但我不认为这是安全的。我的密码将被我的网站的每个用户访问。



有没有其他方法?

解决方案

只有 的FTP帐户可以访问FTP服务器上映像的文件夹。为了获得更好的整体解决方案,可以将图像同步到您的网络服务器,或者编写一个HTTP处理程序来获取服务器端的图像,以及将字节流式传输到客户端,就好像该映像在您的服务器上一样。看看 System.Net .FtpWebRequest 为第二个解决方案。



如果您可以在Web服务器上对磁盘进行写入访问,则可以实现解决方案的两个部分。因此,如果第一次获取镜像,请在将镜像发送到客户端之前将其写入磁盘。下一次请求时,只需将请求重定向到磁盘上的映像(或动态更改该产品的< img> 标签的URL)。这样,随着时间的推移,您可以在Web服务器上创建图像缓存。当然,如果图像更新,您需要能够使缓存无效。


I just go through Google search before posting this question here but I am not happy with my Google results. I hope someone can help me here.

I have an eCommerce site. All the images are stored in a different ftp server. I need to show all the images on my webpage. When page laods it ask for FTP username and password. I can avoid it by giving username and password in FTP URL. But I do not think it is secure. My password will be accessible to every user of my site.

Is there any other way?

解决方案

You really should create an FTP account that only has access to the folder with the images on your FTP server. Do that as soon as possible.

For a better overall solution, either synchronize the images to your webserver, or write an HTTP handler that will fetch the image server-side and streams the bytes to the client as if the image was on your server. Have a look at System.Net.FtpWebRequest for the second solution.

If you have write access to disk on the web server, you could implement both parts of the solution. So if an image is fetched the first time, write it to disk before sending it to the client. The next time it's requested, simply redirect the request to the image on disk (or dynamically change the URL of the <img> tag for that product). This way, you build a cache of the images on your web server as time passes. Of course, you need to be able to invalidate the cache in case an image is updated.

这篇关于FTP链接的用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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