当前位置:网站首页>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");
}
}
}

边栏推荐
猜你喜欢

Unity-UI-shadow组件

2021 programming language ranking summary

ES6 use of return in arrow function

ACM notes

The practice of traffic and data isolation in vivo Reviews

在idea中,get和set方法爆红可能是没有安装Lombok插件

SOC clock configuration

GoLand IDE and delve debug Go programs in kubernetes cluster

Design of DSP image data stream

Sword finger offer|: linked list (simple)
随机推荐
Kubernetes theoretical basis
Redis one master multi slave cluster setup
Resizing node of rediscluster cluster cluster mode
In idea, the get and set methods may be popular because the Lombok plug-in is not installed
什么是EC鼓风机(ec blower fan)?
Construction and exploration of vivo database and storage platform
剑指Offer||:链表(简单)
flutter 实现摇一摇功能
kubelet驱逐机制的源码分析
网传互联网公司加班表,排名第一的没悬念
Localization SoC development plan
[thanos source code analysis series]thanos query component source code analysis
Is it safe for flush to open an account online
GoLand IDE and delve debug Go programs in kubernetes cluster
Can okcc call centers work without computers?
ES6 use of return in arrow function
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
What is the lifecycle of automated testing?
协程、asyncio、异步编程
腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者