❶ c#怎樣從資料庫讀取圖片並保存到指定文件
SqlDataAdapter da = new SqlDataAdapter("select * from newpicture", conn);
DataSet ds = new DataSet();
da.Fill(ds, "pic");
string picdotname;
string picfilename;
int piclength;
int i;
//添加新列
DataColumn newcolumn = ds.Tables["pic"].Columns.Add("pic_url", typeof(string));
for (i = 0; i < Convert.ToInt16(ds.Tables["pic"].Rows.Count); i++)
{
picdotname = ds.Tables["pic"].Rows[i]["pic_dot"].ToString();
piclength = Convert.ToInt32(ds.Tables["pic"].Rows[i]["pic_length"]);
picfilename = Server.MapPath("temp/") + "temp" + i.ToString() + "." + picdotname;
FileStream fs = new FileStream(picfilename, FileMode.Create, FileAccess.Write);
byte[] piccontent = new byte[piclength];
piccontent = (byte[])ds.Tables["pic"].Rows[i]["pic_content"];
fs.Write(piccontent, 0, piclength);
fs.Close();
ds.Tables["pic"].Rows[i]["pic_url"] = "temp/temp" + i.ToString() + "." + picdotname;//相對路徑,改成你自己的文件夾
}
數據源 = ds.Tables["pic"];//數據綁定
大體是這樣吧,裡面表名列名很多細節你按你的表修改吧!
用哪個控制項都行,只要圖片路徑正確就能顯示的
❷ 怎樣用c#將picturebox中的圖片保存到指定文件夾中,是純c#不是.net
1.C#與.NET是不同的概念,.NET是微軟提供的託管代碼的公共框架,C#是運行於其上的一種高級語言。
2.保存圖片代碼
//取得PictureBox中的圖片對象
Image imgSave = picturebox1.Image;
//保存到本地,路徑可自行設置
imgSave.Save("D:\\Image\\mypic.jpg");
❸ 易語言怎麼把圖片框的圖片保存到指定文件夾
解決這個問題的方法如下:
1、首先打開易語言軟體。
❹ vb中如何保存一張圖片在指定文件夾里
'定義一個目錄及文件名變數
dim curDire as string
dim curFile as string
'賦值
curDire=App.Path+"\1" '當前系統目錄下的 ...\1子目錄
curFile=curDire + "\f1234.bmp" '文件名為 f1234.bmp 圖片文件
'判斷子目錄是否存在,不存在則創建
If Len(Dir$(curDire,vbDirectory)) = 0 Then MkDir curDire
'判斷文件是否存在,如存在就刪除該文件
if Len(Dir$(curFile))>0 Then Kill curFile
'將Picture1 中的圖片文件保存
SavePicture Picture1.Image, curFile
❺ PS處理好圖片後怎麼快速保存圖片到指定的文件夾比如按一下就保存了
分2種情況:
1、用修改後的圖片直接替換原圖,快捷鍵「ctry+s」即可保存到原圖所在的文件夾,並替換原圖
2、把修改後的圖片副本保存到指定文件夾,快捷鍵「Ctrl+Shift+S 」,彈出另存窗口,選擇指定的文件夾保存。
另,也可以自己利用「動作」設置快捷鍵,實現相應操作,並存儲。
❻ 在C#(c/s)中如何實現將打開的圖片保存到指定的文件夾中
public static int SaveImageFromWeb(string imgUrl,string path,string fileName)
...{
if(path.Equals(\"\"))
throw new Exception(\"未指定保存文件的路徑\");
string imgName = imgUrl.ToString().Substring(imgUrl.ToString().LastIndexOf(\"/\")+1);
string defaultType = \".jpg\";
string[] imgTypes = new string[]...{\".jpg\",\".jpeg\",\".png\",\".gif\",\".bmp\"};
string imgType = imgUrl.ToString().Substring(imgUrl.ToString().LastIndexOf(\".\"));
foreach (string it in imgTypes)
...{
if (imgType.ToLower().Equals(it))
break;
if (it.Equals(\".bmp\"))
imgType = defaultType;
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(imgUrl);
request.UserAgent = \"Mozilla/6.0 (MSIE 6.0; Windows NT 5.1; Natas.Robot)\";
request.Timeout = 3000;
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
if( response.ContentType.ToLower().StartsWith(\"image/\") )
...{
byte[] arrayByte = new byte[1024];
int imgLong = (int)response.ContentLength;
int l = 0;
if(fileName == \"\")
fileName = imgName;
FileStream fso = new FileStream(path+fileName+imgType,FileMode.Create);
while(l<imgLong)
...{
int i = stream.Read(arrayByte,0,1024);
fso.Write(arrayByte,0,i);
l += i;
}
fso.Close();
stream.Close();
response.Close();
return 1;
}
else
...{
return 0;
}
}
❼ JS中如何把上傳的圖片保存到指定文件目錄
用JSPSMART處理,參考下面代碼實現
<%
//程序初始化 下面設置成要保存的文件夾
String path_tmp = request.getRealPath("/") + "Upload";
String filename_p = "Test";
String path_new = request.getRealPath("/") + "Upload\\" + filename_p;
//文件上傳
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.upload();
int count = su.save(path_tmp);
//參數提取,後面貼不了,說我的重復內容多,這玩意真差...
%>
❽ 在java 中在代碼中要引用的圖片該放在哪個文件
放到任意文件夾都可以,看你的管理方式。
1、放到和程序目錄下的某個文件夾中。
//假設圖片放到程序運行目錄的img目錄下
BufferedImageimg=ImageIO.read(newFile("img/my.png"));
2、放到源文件中,和讀取類在同一目錄,使用時圖片要按包名打包到jar中
//假設圖片放到src下,和MyImages在一個目錄
BufferedImageimg=ImageIO.read(MyImages.class.getResource("my.png"));
3、放到源文件中,但在獨立文件夾中,使用時圖片要按包名打包到jar中
//假設圖片放到src下的img目錄中
BufferedImageimg=ImageIO.read(MyImages.class.getResource("res/my.png"));
❾ js中如何將某地址的圖片保存到本地指定文件夾中
用JSPSMART處理,參考下面代碼實現:
<%
//程序初始化 下面設置成要保存的文件夾。
String path_tmp = request.getRealPath("/") + "Upload";
String filename_p = "Test";
String path_new = request.getRealPath("/") + "Upload\" + filename_p;
//文件上傳。