當前位置:首頁 » 文件管理 » aspnet圖片上傳預覽

aspnet圖片上傳預覽

發布時間: 2022-08-11 07:01:10

❶ asp.net(C#)上傳用fileupload顯示在image圖片中的方法

我覺著你可以把文件保存到本地路徑,然後把圖片存的路徑存儲資料庫,讀取的時候去資料庫去路徑就行了

❷ c# asp.net中 用fileupload控制項上傳圖片

首先要看你想實現如何存儲圖片數據,有兩種形式;
第一在資料庫中存儲圖片的路徑,這樣需要將上傳的圖片存儲到遠程伺服器的磁碟上,然後獲取圖片的路徑存儲到資料庫中。
第二將圖片的數據存儲到資料庫中,這樣做不需要上傳圖片的路徑的,他的原理是將圖片按照一定的數據格式存儲到資料庫中,在讀取的時候需要用程序將數據取出來然後解碼轉換成你要的圖片格式

❸ asp.net c#怎麼上傳圖片到資料庫,需要添加什麼控制項,說清楚

需要添加FileUpload控制項,通過這個控制項選擇需要上傳的圖片,然後把圖片轉換成二進制流,將二進制流保存到資料庫,讀取的時候再將二進制流轉換成圖片。怎樣轉換你自己查吧,我也忘了。

❹ C#、ASP.NET圖片上傳問題

保存入本地你已經寫完了,剩下的就是路徑保存入access資料庫?

❺ 怎麼運用aspnet製作圖片上傳,修改,增加,刷新,和自動播放。

發老師給的具體要求出來看看,我練習下。

❻ ASP.NET中將上傳的圖片顯示在頁面上(c#語言)

<asp:Image ID="Image1" runat="server" ImageUrl="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-.gif" />
<asp:FileUpload ID="FileUpload1" onpropertychange="document.all.Image1.src=this.value;" runat="server" />

❼ C# ASP.NET 如何上傳圖片進資料庫 我用的是VS2010。

在得到圖片的時候自己寫一個方法將圖片轉化成二進制流的形式存入資料庫:
private byte[] ConvertPicture()
{
string path = FileUpload1.FileName //記錄圖片所在的路徑
byte[] byteImage = null; // 初始化一個位元組數組儲存圖片
FileStream FStream = new FileStream(path , FileMode.Open, FileAccess.Read); //將圖片以文件流的形式進行保存
BinaryReader BReader = new BinaryReader(FStream);
byteImage = BReader.ReadBytes((int)FStream.Length);
BReader.Close();
FStream.Close();
return byteImage;
}
在資料庫中讀取出二進制流的圖片:
byte[] bytes = model.EmployeeImage;
MemoryStream ms = new MemoryStream(bytes);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
this.Image1 = img;

❽ Asp.net(c#)文件上傳於下載

我這里有個上傳的函數,下載的還沒做過(新手,目前還沒用到),你看看吧能不能用了。

public void Upload(string path, System.Web.UI.WebControls.FileUpload fileupload)
{
bool fileOK = false;
if (FileUpload1.HasFile)
{
string fileException = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
//獲取指定路勁字元串的後綴名,並轉化為小寫
string[] allowExcption = { ".jpg", ".jpeg", ".bmp",".gif" };
//定義允許的後綴名
for (int i = 0; i < allowExcption.Length; i++)
{
if (fileException == allowExcption[i])
{
fileOK = true;
}
}
}

if (fileOK)
{
//判斷文件是否存在,若不在則創建路徑
if (System.IO.Directory.Exists(path))
{
//MessageBox.Show("該目錄已經存在","信息提示");
}
else
{
System.IO.Directory.CreateDirectory(path);//創建文件路徑
}
fileupload.SaveAs(path + "\" + fileupload.FileName);//上傳文件
}
else
{
Response.Write("<Script>alert('不支持此格式文件上傳')</Script>");
return;
}
}






protected void Button1_Click(object sender, EventArgs e)
{
string serverpath = Server.MapPath("~/ImageFile");
string imapath = "~/ImageFile/" + FileUpload1.FileName;
Upload(serverpath, this.FileUpload1);
Image1.ImageUrl = imapath;

serverpath = Server.MapPath("~/ImageFile");
imapath = "~/ImageFile/" + FileUpload1.FileName;
Image1.ImageUrl = imapath;
Upload(serverpath, this.FileUpload1);
}

這部分是調用的(預覽的功能),你要上傳的話改成資料庫操作就可以了,存放上傳的路勁,文件的話她會自動生成文件夾放在裡面的。

❾ ASP.NET+C#,FILEUPLOAD控制項,如何上傳圖片到伺服器,並保存圖片路徑到資料庫

我做了個例子給你
前台:
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server"
Text="Button" onclick="Button1_Click" />
<asp:Image ID="Image1" runat="server" />
</div>
後台:
protected void Button1_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs(Server.MapPath("img/"+FileUpload1.FileName));//上傳圖片
Image1.ImageUrl = "~/img/" + FileUpload1.FileName;//圖片路徑(將這個數據保存到資料庫就可以了。img為項目里一個文件夾的名稱)
}

❿ C#.net 實現上傳前先圖片預覽

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>無標題頁</title>
<script language="javascript" type="text/javascript">
function Preview(imgSrc)
{
document.getElementById("Image1").src = imgSrc;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" Width="100px" runat="server" />
<asp:FileUpload ID="FileUpload1" runat="server" onchange="Preview(this.value);" />
</div>
</form>
</body>
</html>

熱點內容
app什麼情況下找不到伺服器 發布:2025-05-12 15:46:25 瀏覽:714
php跳過if 發布:2025-05-12 15:34:29 瀏覽:467
不定時演算法 發布:2025-05-12 15:30:16 瀏覽:131
c語言延時1ms程序 發布:2025-05-12 15:01:30 瀏覽:165
動物園靈長類動物配置什麼植物 發布:2025-05-12 14:49:59 瀏覽:734
wifi密碼設置什麼好 發布:2025-05-12 14:49:17 瀏覽:148
三位數乘兩位數速演算法 發布:2025-05-12 13:05:48 瀏覽:397
暴風影音緩存在哪裡 發布:2025-05-12 12:42:03 瀏覽:541
access資料庫exe 發布:2025-05-12 12:39:04 瀏覽:628
五開的配置是什麼 發布:2025-05-12 12:36:37 瀏覽:365