新聞中心
vb.net ftp上傳文件
Dim OpenFileDialog As New OpenFileDialog
延吉ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格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
第一個按鈕 上傳
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)
第二個按鈕
VB.net 讀取文本文件?
1、實現(xiàn)上傳按鈕方法代碼。
2、判斷圖片對象是否為空代碼。
3、取得數(shù)據(jù)庫字段 dt.Rows(0)("Pic")方法代碼。
4、字節(jié)數(shù)組轉(zhuǎn)換為Image類型方法代碼。
5、處理SQL中操作Image類型方法代碼。
6、實現(xiàn)的上傳結(jié)果。
怎么讓VB.NET 上傳圖片到SQL 數(shù)據(jù)庫只保存路徑,圖片保存到文件
圖片和文件的記錄加個地址的字段,字段內(nèi)容是文件和圖片的絕對路徑就好了,那就把圖片和文件弄成2進制存進去,或轉(zhuǎn)成hash值
vb.net如何上傳文件
My.Computer.Network.UploadFile
比如上傳到FTP
My.Computer.Network.UploadFile("d:\1.txt", "“, "FTP賬號", "FTP密碼", True, 100)
新手路過。
asp.net以及VB做的網(wǎng)站,現(xiàn)在需要限制上傳文件的格式,比如我只想上傳jpg和doc格式的文件,求教方法
%@ language="javascript"%
%
var self = Request.serverVariables("SCRIPT_NAME");
if (Request.serverVariables("REQUEST_METHOD")=="POST")
{
var oo = new uploadFile();
oo.path = "../../images/swf/"; //存放路徑,為空表示當前路徑,默認為uploadFile
oo.named = "date"; //命名方式,date表示用日期來命名,file表示用文件名本身,默認為file
oo.ext = "all"; //允許上傳的擴展名,all表示都允許,默認為all
oo.over = true; //當存在相同文件名時是否覆蓋,默認為false
oo.size = 1*1024*1024; //最大字節(jié)數(shù)限制,默認為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("目前暫不支持擴展名為 "+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("對不起,此文件已存在!");
}
oo.close();
delete(oo);
}
//獲取二進制和文件字節(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
分享名稱:vb.net文件上傳 vbs上傳文件
當前URL:http://fisionsoft.com.cn/article/dodsipo.html