Dim OpenFileDialog As New OpenFileDialog
延吉ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!
OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "文本文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = OpenFileDialog.FileName
' TODO: 在此處添加打開文件的代碼。
textbox1.Text = FileName
End If
第一個(gè)按鈕 上傳
Dim filelast As String = fileaddbefore.Text.Substring(fileaddbefore.Text.LastIndexOf("."), fileaddbefore.Text.Length - fileaddbefore.Text.LastIndexOf("."))
MessageBox.Show(filelast)
My.Computer.Network.UploadFile(textbox1.Text, "" 文件名.Text filelast, "登錄名1", "登錄密碼", True, 100)
第二個(gè)按鈕
1、實(shí)現(xiàn)上傳按鈕方法代碼。
2、判斷圖片對(duì)象是否為空代碼。
3、取得數(shù)據(jù)庫字段 dt.Rows(0)("Pic")方法代碼。
4、字節(jié)數(shù)組轉(zhuǎn)換為Image類型方法代碼。
5、處理SQL中操作Image類型方法代碼。
6、實(shí)現(xiàn)的上傳結(jié)果。
圖片和文件的記錄加個(gè)地址的字段,字段內(nèi)容是文件和圖片的絕對(duì)路徑就好了,那就把圖片和文件弄成2進(jìn)制存進(jìn)去,或轉(zhuǎn)成hash值
My.Computer.Network.UploadFile
比如上傳到FTP
My.Computer.Network.UploadFile("d:\1.txt", "“, "FTP賬號(hào)", "FTP密碼", True, 100)
新手路過。
%@ language="javascript"%
%
var self = Request.serverVariables("SCRIPT_NAME");
if (Request.serverVariables("REQUEST_METHOD")=="POST")
{
var oo = new uploadFile();
oo.path = "../../images/swf/"; //存放路徑,為空表示當(dāng)前路徑,默認(rèn)為uploadFile
oo.named = "date"; //命名方式,date表示用日期來命名,file表示用文件名本身,默認(rèn)為file
oo.ext = "all"; //允許上傳的擴(kuò)展名,all表示都允許,默認(rèn)為all
oo.over = true; //當(dāng)存在相同文件名時(shí)是否覆蓋,默認(rèn)為false
oo.size = 1*1024*1024; //最大字節(jié)數(shù)限制,默認(rèn)為1G
oo.upload();
Response.write('script type="text/javascript"location.replace("'+self+'")/script');
}
//ASP無組件上傳類
function uploadFile()
{
var bLen = Request.totalBytes;
var bText = Request.binaryRead(bLen);
var oo = Server.createObject("ADODB.Stream");
oo.mode = 3;
this.path = "uploadFile";
this.named = "file";
this.ext = "all";
this.over = false;
this.size = 1*1024*1024*1024; //1GB
//文件上傳
this.upload = function ()
{
var o = this.getInfo();
if (o.sizethis.size)
{
alert("文件過大,不能上傳!");
return;
}
var f = this.getFileName();
var ext = f.replace(/^.+\./,"");
if (this.ext!="all"!new RegExp(this.ext.replace(/,/g,"|"),"ig").test(ext))
{
alert("目前暫不支持?jǐn)U展名為 "+ext+" 的文件上傳!");
return;
}
if (this.named=="date")
{
var f = new Date().toLocaleString().replace(/\D/g,"") + "." + ext;
}
oo.open();
oo.type = 1;
oo.write(o.bin);
this.path = this.path.replace(/[^\/\\]$/,"$/");
var fso = Server.createObject("Scripting.FileSystemObject");
if(this.path!=""!fso.folderExists(Server.mapPath(this.path)))
{
fso.createFolder(Server.mapPath(this.path));
}
try
{
oo.saveToFile(Server.mapPath(this.path+f),this.over?2:1);
Response.write('script type="text/javascript"parent.form.swf_Pic.value=("images/swf/'+f+'")/script');
alert(f);
}
catch(e)
{
alert("對(duì)不起,此文件已存在!");
}
oo.close();
delete(oo);
}
//獲取二進(jìn)制和文件字節(jié)數(shù)
this.getInfo = function ()
{
oo.open();
oo.type=1;
oo.write(bText);
oo.position = 0;
oo.type=2;
oo.charset="unicode";
var gbCode=escape(oo.readText()).replace(/%u(..)(..)/g,"%$2%$1");
var sPos=gbCode.indexOf("%0D%0A%0D%0A")+12;
var sLength=bLen-(gbCode.substring(0,gbCode.indexOf("%0D%0A")).length/3)-sPos/3-6;
oo.close();
oo.open();
oo.type = 1;
oo.write(bText);
oo.position=sPos/3;
var bFile=oo.read(sLength);
oo.close();
return { bin:bFile, size:sLength };
}
//獲取文件名
this.getFileName = function ()
{
oo.open();
oo.type = 2;
oo.writeText(bText);
oo.position = 0;
oo.charset = "gb2312";
var fileName = oo.readText().match(/filename=\"(.+?)\"/i)[1].split("\\").slice(-1)[0];
oo.close();
return fileName;
}
function alert(msg)
{
Response.write('script type="text/javascript"alert("'+msg+'");/script');
}
}
%
body topmargin="0" marginwidth="0"
form action="%=self%" method="POST" enctype="multipart/form-data" onSubmit="return (this.upFile.value!='');" name="myform" style="border: 1px solid #C0C0C0"
input type="file" name="upFile" size="21"/
input type=submit name=submit value=上傳 class="tx1"
/form
標(biāo)題名稱:vb.net文件上傳 vbs上傳文件
鏈接URL:http://chinadenli.net/article30/dodsipo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、靜態(tài)網(wǎng)站、做網(wǎng)站、用戶體驗(yàn)、手機(jī)網(wǎng)站建設(shè)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)