新手菜鸟项目:将图片上传到windows远程服务器并获取URL,记录到sql server,通过数据库记录的地址显示图片
目前直接通过ftp://username:password@ip地址/1.jpg的路径方式想访问图片在visual studio无法直接访问。
其中:谷歌和其他浏览器无法通过FTP远程访问阿里ECSwindows服务器中的图片,IE却可以
谷歌浏览器:无法访问服务器及图片
IE浏览器:能访问服务器及图片
文件资源管理器:能访问服务器,但不能打开图片,点击就会跳转谷歌网页端访问
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ShowImage();
}
private string pathname = string.Empty; //定义路径名变量
public void ShowImage()
{
pathname = "ftp://username:password@ip地址/1.jpg";//实际测试时替换成实际账号密码
if (pathname != string.Empty)
{
try
{
this.pictureBox1.Load(pathname);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
运行显示