当前位置:网站首页>asp. Net upload image path and image name
asp. Net upload image path and image name
2022-06-28 07:42:00 【No. 1006 Xiaobai】
Store the image path to the database , Next time, the image path in the database will be assigned to image perhaps img Control
<div class="row">
<div class="col-xs-3 text-center custom-add-title"><label class="control-label"> Please select a picture to upload :</label></div>
<div class="col-xs-6">
<div class = "input-group">
<asp:FileUpload ID="FileUpload1" runat="server" />
</div>
</div>
</div>
<div class="row">
<asp:Button ID="btnsumbit" CssClass="sumbit" runat="server" Text=" Submit " OnClick="btnsumbit_Click" />
</div>

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class BackGround_AddInfo : System.Web.UI.Page
{
Operation operation = new Operation();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsumbit_Click(object sender, EventArgs e)
{
string path = Server.MapPath("~/images/new/"); // Get file path
string name = FileUpload1.FileName; // Get the file name
string ipath = "~/images/new" + "\\" + name; // Storage path ( With picture name )
string type = FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1); // Get file type
// Put the goods ( name 、 Price 、 describe 、 route ) Save to database
operation.InsertFiles(txtName.Text.Trim(),Convert.ToInt32(txtPrice.Text), txtDetails.Text.Trim(),ipath);
// Query according to the product name
if (operation.SelectFiles(txtName.Text.Trim()).Tables["good_info5"].Rows.Count > 0)
{
WebMessageBox.Show(" Successfully added product information !", "AddInfo.aspx");
}
else
{
WebMessageBox.Show(" Failed to add product information , Please re add ", "AddInfo.aspx");
}
}
}

边栏推荐
猜你喜欢

flex布局

Section 5: zynq interrupt

Sentinel mechanism of redis cluster

The practice of traffic and data isolation in vivo Reviews

Design and implementation of spark offline development framework

Alibaba cloud server creates snapshots and rolls back disks

8 figures | analyze Eureka's first synchronization registry

Uninstall and reinstall the latest version of MySQL database. The test is valid

Solving the longest palindrome substring by dynamic programming

Section VI UART of zynq
随机推荐
云原生:云计算技术再次升级 开启全面云开发时代
协程、asyncio、异步编程
Uninstall and reinstall the latest version of MySQL database. The test is valid
HJ字符个数统计
R language hitters data analysis
Practice of traffic recording and playback in vivo
kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑
腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者
Introduction and several months' experience of extending the solution thanos of Prometheus
A gadget can write crawlers faster
推荐系统系列精讲(第五讲): 排序模型的调优实践
Open62541 import nodeset file directly
HTTP Caching Protocol practice
Cloud native (to be updated)
Evolution of vivo push platform architecture
Can okcc call centers work without computers?
Unity UI shadow component
7-2 Finnish wooden chess structure Sorting
ACM notes
Dbeaver 22.1.1 release, visual database management platform