㈠ C#圖片批量上傳C/S端的
我來告訴你標准答案!上網找一下,現在有很多別人已經實現的插件可以用
㈡ C#如何上傳圖片
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
/// <summary>
/// 圖片處理
/// </summary>
public class FilePath
{
public FilePath()
{
//
//TODO: 在此處添加構造函數邏輯
//
}
/**/
/// <summary>
/// 生成縮略圖
/// </summary>
/// <param name="originalImagePath">源圖路徑(物理路徑)</param>
/// <param name="thumbnailPath">縮略圖路徑(物理路徑)</param>
/// <param name="width">縮略圖寬度</param>
/// <param name="height">縮略圖高度</param>
/// <param name="mode">生成縮略圖的方式</param>
public static void MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)
{
System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);
int towidth = width;
int toheight = height;
int x = 0;
int y = 0;
int ow = originalImage.Width;
int oh = originalImage.Height;
switch (mode)
{
case "HW"://指定高寬縮放(可能變形)
break;
case "W"://指定寬,高按比例
toheight = originalImage.Height * width / originalImage.Width;
break;
case "H"://指定高,寬按比例
towidth = originalImage.Width * height / originalImage.Height;
break;
case "Cut"://指定高寬裁減(不變形)
if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
{
oh = originalImage.Height;
ow = originalImage.Height * towidth / toheight;
y = 0;
x = (originalImage.Width - ow) / 2;
}
else
{
ow = originalImage.Width;
oh = originalImage.Width * height / towidth;
x = 0;
y = (originalImage.Height - oh) / 2;
}
break;
default:
break;
}
//新建一個bmp圖片
System.Drawing.Image bitmap = new System.Drawing.Bitmap(towidth, toheight);
//新建一個畫板
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
//設置高質量插值法
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//設置高質量,低速度呈現平滑程度
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//清空畫布並以透明背景色填充
g.Clear(System.Drawing.Color.Transparent);
//在指定位置並且按指定大小繪制原圖片的指定部分
g.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, towidth, toheight),
new System.Drawing.Rectangle(x, y, ow, oh),
System.Drawing.GraphicsUnit.Pixel);
try
{
//以jpg格式保存縮略圖
bitmap.Save(thumbnailPath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (System.Exception e)
{
throw e;
}
finally
{
originalImage.Dispose();
bitmap.Dispose();
g.Dispose();
}
}
/**/
/// <summary>
/// 在圖片上增加文字水印
/// </summary>
/// <param name="Path">原伺服器圖片路徑</param>
/// <param name="Path_sy">生成的帶文字水印的圖片路徑</param>
/// <param name="addText">水印文字內容</param>
/// <param name="Fontname">字體大小</param>
/// <param name="Draw">文字左邊距離</param>
/// <param name="Drah">文字右邊距離</param>
public static void AddWater(string Path, string Path_sy, string addText, int Fontname, int Draw, int Drah)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
System.Drawing.Font f = new System.Drawing.Font("Verdana", Fontname);
System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
g.DrawString(addText, f, b, 35, 35);
g.Dispose();
image.Save(Path_sy);
image.Dispose();
}
/**/
/// <summary>
/// 在圖片上生成圖片水印
/// </summary>
/// <param name="Path">原伺服器圖片路徑</param>
/// <param name="Path_syp">生成的帶圖片水印的圖片路徑</param>
/// <param name="Path_sypf">水印圖片路徑</param>
public static void AddWaterPic(string Path, string Path_syp, string Path_sypf)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Image Image = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(Image, new System.Drawing.Rectangle(image.Width - Image.Width, image.Height - Image.Height, Image.Width, Image.Height), 0, 0, Image.Width, Image.Height, System.Drawing.GraphicsUnit.Pixel);
g.Dispose();
image.Save(Path_syp);
image.Dispose();
}
//// <summary>
/// 刪除文件文件或圖片
/// </summary>
/// <param name="path">當前文件的路徑</param>
/// <returns>是否刪除成功</returns>
public static bool FilePicDelete(string path)
{
bool ret = false;
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
file.Delete();
ret = true;
}
return ret;
}
}
㈢ 為什麼我只能從c:單張上傳相片到百度雲
重新下載網路雲,安裝網路雲,你可以選擇上傳的路徑的。
㈣ 有一個C開頭的上傳圖片的網站網址是多少來這
是這個吧
c.imqqjs.com
我都是用這個上傳圖片,挺穩定的。
㈤ C證怎麼下載的照片怎麼上傳
咨詢記錄 · 回答於2021-09-30
㈥ 在C#中,如何實現上傳圖像的功能……
參考代碼如下:string filepath = FileUpload1.PostedFile.FileName;
string filename = filepath.Substring(filepath.LastIndexOf( "\\ "));
string fileEx = filepath.Substring(filepath.LastIndexOf( ". ")+1);
string serverpath = "C:/aa/upload/ " + filename;
string dbpath = "\\upload\\ " + filename;
if (fileEx == "jpg " || fileEx == "bmp " || fileEx == "gif ")
{
FileUpload1.PostedFile.SaveAs(serverpath);
Response.Write( "成功 ");
Image1.ImageUrl = @ "..\aa\upload\ " + filename;
}
else
{
Response.Write( "失敗 ");
}
string sql = "insert into gc_carno(id,carno,model,carphoto) values(100, ' "+TextBox1.Text+ " ', ' "+TextBox2.Text+ " ', ' "+dbpath+ " ') ";
OracleConnection conn = sda.getoracleconnection();
conn.Open();
OracleCommand cmd = new OracleCommand(sql,conn);
int i = cmd.ExecuteNonQuery();
if (i == 1)
{
Response.Write( " <script language= 'javascript '> alert( '添加成功 ') </script> ");
}
else
{
Response.Write( " <script language= 'javascript '> alert( '添加失敗 ') </script> ");
}
在資料庫存儲的是伺服器圖片的物理地址,數據類型是varchar型。
㈦ 怎樣從電腦上往8010c上傳圖片啊
藍牙,紅外,數據線。彩信。
㈧ C/S程序如何上傳圖片文件到伺服器
以文件形式保存在一個文件夾里,文件名用GUID方式命名
㈨ e251c上傳照片
要安PC STUDIO 才行 這樣手機的內存才能連接上
或者你可以先把照片復制到存儲卡上 然後在從存儲卡上移到電腦裡面去
㈩ 我在報名2級c語言,照片上傳時顯示javascript:_doPostBack("btnUpload"),是什麼問題,怎麼改
是javascript提交表單的機制,__doPostBack(eventTarget,eventArgument),eventTarget點擊的對象比如button,eventArgument是事件的參數,button的onclick事件轉化成HTML語言就是對應的__doPostBack(button的Name,''),javascript:__doPostBack('anp1','2'),anp1可能是換頁的,如果是頁面的話,就是anp1為頁面控制項,2為頁碼索引為第三頁,找後台的anp1控制項的SelectIndex_change後台事件