1. 上传图片并 保存到自己的路径
private void gtisButton1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialogTemp = new OpenFileDialog(); openFileDialogTemp.Title = "选择要上传的图片"; openFileDialogTemp.Filter = "All Files(*.*)|*.*|位图(*.bmp)|*.bmp|JPEG(*.jpg)|*.jpg"; DialogResult dr = openFileDialogTemp.ShowDialog(); textBox1.Text = openFileDialogTemp.FileName; if (!File.Exists(openFileDialogTemp.FileName)) { MessageBox.Show("照片为空,请选择图片"); return; } if (dr == DialogResult.OK) { string image = openFileDialogTemp.FileName; string picpath = openFileDialogTemp.FileName; pictureBox1.Image = Image.FromFile(image); this.pictureBox1.Text = image; string id = "111"; File.Copy(openFileDialogTemp.FileName, Application.StartupPath + "\\Image\\" + id + ".jpg"); } }
2. 参考链接
https://www.cnblogs.com/right_forever/archive/2011/05/31/2064257.html
https://www.cnblogs.com/lingbohome/p/4655043.html