當前位置:首頁 » 文件管理 » 有組件上傳

有組件上傳

發布時間: 2022-09-07 15:07:07

Ⅰ ASP無組件與有組件上傳問題

upfile.asp
------------------------------------------------------
<!--#include FILE="upload.inc"-->

<html>
<head>
<title>文件上傳</title>
</head>
<body>
<%
dim arr(3)
dim upload,file,formName,formPath,iCount,filename,fileExt,i,filepath
set upload=new upload_5xSoft ''建立上傳對象

formPath=upload.form("filepath")
filepath=upload.form("filepath")
''在目錄後加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
iCount=0
i=0
for each formName in upload.file ''列出所有上傳了的文件
set file=upload.file(formName) ''生成一個文件對象

if file.filesize<0 then
response.write "<font size=2>請先選擇你要上傳的圖片 [ <a href=# onclick=history.go(-1)>重新上傳</a> ]</font>"
response.end
end if

if file.filesize>100000 then
response.write "<font size=2>圖片大小超過了限制 [ <a href=# onclick=history.go(-1)>重新上傳</a> ]</font>"
response.end
end if
'if fileEXT<>".gif" and fileEXT<>".jpg" then
'response.write "<font size=2>文件格式不對 [ <a href=# onclick=history.go(-1)>重新上傳</a> ]</font>"
'response.end
'end if

'filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&file.FileName

filename=formPath&file.filename

'fileExt=len(file.filename)

'fileExt=lcase(right(file.filename,4))
'response.write fileExt
arr(i)=filename
i=i+1

if file.FileSize>0 then ''如果 FileSize > 0 說明有文件數據
file.SaveAs Server.mappath(filename) ''保存文件
' response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 成功!<br>"

iCount=iCount+1
end if
set file=nothing
next
if instr(arr(0),".")=0 and instr(arr(1),".")=0 and instr(arr(2),".")=0 then
response.write "<font size=2>請先選擇你要上傳的圖片 [ <a href=# onclick=history.go(-1)>重新上傳</a> ]</font>"
response.end
end if

set upload=nothing ''刪除此對象

session("upface")="done"

Htmend iCount&" 個文件上傳結束!"

sub HtmEnd(Msg)
set upload=nothing
response.write "<html><head><meta http-equiv='Refresh' content='2 url=""javascript:window.close();""'></head><body><center> <br><br>文件上傳成功!<br>謝謝你的支持!<br>本窗口二秒後自動關閉< /center></body></html>"
response.end
end sub
%>
</body>
</html>

upload.inc
-----------------------------------------------------------------------
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>

dim upfile_5xSoft_Stream

Class upload_5xSoft

dim Form,File,Version

Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version=""
if Request.TotalBytes<1 then Exit Sub
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)

vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)

if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if

iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub

Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function

Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function

Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub

Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function

Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function

Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class

Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub

Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.to dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
</SCRIPT>
------------------

Ⅱ 怎麼寫組件並且上傳到github

首先確認:擁有一個GitHub賬號,已經安裝 Git。
先在GitHub創建一個項目,名字隨意,盡量全部小寫字母,避免隨後會碰到的URL沖突問題
本地運行Git,隨意選個目錄,將剛才創建的項目clone下來。
在項目的根目錄下新建文件 _config.yml ,填寫 baseurl: /blogdemo , blogdemo是你的項目名稱,這一行內容規定了整個網站的根路徑。
在項目的根目錄下新建文件 _config.yml ,填寫 baseurl: /blogdemo , blogdemo是你的項目名稱,這一行內容規定了整個網站的根路徑。
回到git bash, 檢查一下 git status ,確認 _config.yml 與 index.html 無誤後 add,commit,保持使用Git的良好習慣,記得添加提交描述然後推送到GitHub,這里注意,因為我們使用的是GitHub Pages中的 Project Pages, GitHub僅會將分支 gh-pages 下的內容進行自動生成操作, 所以本地的 master 分支應推送到遠端的 gh-pages 分支。
稍微等待一下,最多10分鍾(通常不用那麼久啦),訪問yourname.github.com/blogdemo ,(其中 yourname 是你的GitHub帳戶名,blogdemo則是你的項目名)就會看見你新建的項目了

Ⅲ extjs怎樣判斷formpanel中有文件上傳組件

java代碼中對文件上傳的處理可以參考struct的文件上傳,但是在返回處理結果時必須設置 response.setContentType("text/HTML"); 否則文件上傳後,會出現一個下載對話框; var formPanel = new Ext.FormPanel({ }) 中必須加入fileUpload:true

Ⅳ asp後台圖片用組件上傳了,但是資料庫一直添加不了,有源文件,請高手幫忙解決,急

我從我做的系統中截取了一部分(與你的提問有關聯的)代碼,並稍做注釋,希望能幫到你:
----------------------------------------------------
...
Co_picture = Trim(Request.Form("Co_picture"))
Pictures=Split(Co_picture,",")
For X = 0 to Ubound(Pictures)
IF instr(Pictures(X),"uploadfile")>0 and Len(Pictures(X)) > 11 Then
Pictures(X) = right(Pictures(X),Len(Pictures(X))-11)
Else
End IF
Co_pictures = Co_pictures & "uploadfile/" & Pictures(X) & ","
Next

'Stream.CharSet = "utf-8"
Select Case Action
Case "save"
IF Trim(Request.Form("Co_name"))="" Then
Response.Write("<script language=javascript>alert('對不起,標題不能為空!');history.back();</script>")
Response.End()
End IF
IF Trim(Request.Form("Co_picture"))="" Then
Response.Write("<script language=javascript>alert('請先上傳文件之後再進行此操作!');history.back();</script>")
Response.End()
End IF
Co_recommend = "False"
IF Request.Form("Co_recommend") = "true" Then Co_recommend = "True"
Set MM_Recordset = GetRecordset("Select * from table_Commodity Where Co_name = '" & Trim(Request.Form("Co_name")) & "' order by Co_createdate desc")
IF Not MM_Recordset.Eof Then
Response.Write("<script language=javascript>alert('對不起,您所填寫的商品信息已經存在!');history.back();</script>")
Response.End()
Else

SQLString = "Insert Into table_commodity(" &_
"Co_name,Co_cateID,Co_picture,Co_clicks,Co_factory,Co_createdate,Co_intro,Co_contact,Co_Website,Co_Email,Co_masterid,Co_recommend)"&_
" Values('" &Trim(Request.Form("Co_name")) & "','" & Trim(Request.Form("Co_cateID")) & "','" & Co_pictures & "',0,'" &Trim(Request.Form("Co_factory")) & "',#" & Now() & "#,'" & Trim(Request.Form("Co_intro")) & "','" &Trim(Request.Form("Co_contact")) & "','" &Trim(Request.Form("Co_Website")) & "','" &Trim(Request.Form("Co_Email")) & "'," & recorderID & "," & Co_recommend & ")"
Response.Write(SQLString)
GetRecordset SQLString
End IF
MM_Recordset.Close
Action=""
.....
<input name="Co_picture" type="text" id="Co_picture" size="50" value="<%=Co_picture%>"/>
<input type="button" value="上傳文件" onClick="showUpload(this,'Co_picture','../uploadfile',10,null);" />
.....

Ⅳ 如何使用文件上傳組件上傳文件

你咋提問提到操作系統去了呢
是C#吧
protected string UpLoad(System.Web.UI.WebControls.FileUpload UP_FILE)//參數是一個上傳控制項
{
string photourl = string.Empty;
//上傳文件
if (UP_FILE.PostedFile.ContentLength > 0)
{
//設定上傳文件的保存路徑

string strName = UP_FILE.PostedFile.FileName;
FileInfo fl =new FileInfo( strName);
//Response.Write(fl.CreationTime.ToString());

string[] strs=strName.Split('\\');
string strSaveDir = "file/" + strs[strs.Length - 1];
//取得文件名(抱括路徑)里最後一個"."的索引
int intExt = strName.LastIndexOf(".");
//取得文件擴展名
string strExt = strName.Substring(intExt);
strExt = strExt.ToLower();
//if (strExt != ".jpeg" && strExt != ".jpg" && strExt != ".gif")
//{
// Response.Write("<script language=javascript> alert('文件類型必須為.gif、.jpg、.jpeg')</script>");
// return;

//}
//if (UP_FILE.PostedFile.ContentLength > 3000000)
//{
// Response.Write("<script language=javascript> alert('圖片大小超過了限制')</script>");
// return;

//}

UP_FILE.PostedFile.SaveAs(Server.MapPath(strSaveDir));

return "上傳成功!";
}
else
{
return "請選擇要上傳的文件!";
}

}

Ⅵ aspupload組件上傳路徑設置的問題

我有,可以限制上傳文件格式,可是刪除文件的資料庫信息,同時刪掉相應的物理文件。可以保存文件的上傳格式,文件大小,文件名等等相關信息到資料庫保存。不過……明天要考試,有空再發給你哦,記住哦,肯定給你的,因為是運用在我的網站裡面的,我網站代碼很多,你研究也很費勁,對不?所以我要有時間再整理出來你要的代碼,再發給你,對不?

Ⅶ 有組件上傳加水印

Sub Image_Obj_1(Imagename,TempFilename,FileExt)
' 讀取要處理的原文件
Dim Draw_X,Draw_Y,Logobox
Draw_X = 0
Draw_Y = 0
FileExt = Lcase(FileExt)
On Error Resume Next
ImageObj.Open Trim(Server.MapPath(Imagename))
If Err Then
err.Clear
Exit Sub
End If
If ImageObj.OriginalWidth<View_ImageWidth or ImageObj.Originalheight<View_ImageHeight Then
TempFilename = ""
Exit Sub
Else
If FileExt<>"gif" and ImageObj.OriginalWidth > Draw_ImageWidth * 2 and Draw_Type >0 Then
Draw_X = DrawImage_X(ImageObj.OriginalWidth,Draw_ImageWidth,2)
Draw_Y = DrawImage_y(ImageObj.Originalheight,Draw_ImageHeight,2)
If Draw_Type=2 Then
Set Logobox = Server.CreateObject("Persits.Jpeg")
'*添加水印圖片 添加時請關閉水印字體*
'//讀取添加的圖片
Logobox.Open Server.MapPath(Draw_Info)
Logobox.Width = Draw_ImageWidth '// 加入圖片的原寬度
Logobox.Height = Draw_ImageHeight '// 加入圖片的原高度
ImageObj.DrawImage Draw_X, Draw_Y, Logobox, Draw_Graph,Transition_Color,90 '// 加入圖片的位置價坐標(添加水印圖片)
'ImageObj.Sharpen 1, 130 '設置銳化值:銳化半徑,深度
ImageObj.Quality=100'設置加水印後圖片的質量
ImageObj.Save Server.MapPath(Imagename)
Set Logobox=Nothing
Else
'//關於修改字體及文字顏色的
ImageObj.Canvas.Font.Color = Draw_FontColor '// 文字的顏色
ImageObj.Canvas.Font.Family = Draw_FontFamily '// 文字的字體
ImageObj.Canvas.Font.Bold = Draw_FontBold
ImageObj.Canvas.Font.Size = Draw_FontSize '//字體大小
' Draw frame: black, 2-pixel width
ImageObj.Canvas.Print Draw_X, Draw_Y, Draw_Info '// 加入文字的位置坐標
ImageObj.Canvas.Pen.Color = &H000000 '// 邊框的顏色
ImageObj.Canvas.Pen.Width = 1 '// 邊框的粗細
ImageObj.Canvas.Brush.Solid = False '// 圖片邊框內是否填充顏色
'ImageObj.Canvas.Bar 0, 0, ImageObj.Width, ImageObj.Height '// 圖片邊框線的位置坐標
ImageObj.Quality=100 '設置加水印後圖片的質量
ImageObj.Save Server.MapPath(Imagename)
End If
End If
If ImageObj.Width > ImageObj.height Then
ImageObj.Width = View_ImageWidth
ImageObj.Height = ViewImage_Height(ImageObj.OriginalWidth,ImageObj.Originalheight,View_ImageWidth,View_ImageHeight)
Else
ImageObj.Width = ViewImage_Width(ImageObj.OriginalWidth,ImageObj.Originalheight,View_ImageWidth,View_ImageHeight)
ImageObj.Height = View_ImageHeight
End If
ImageObj.Sharpen 1, 120
ImageObj.Save Server.MapPath(TempFilename) '// 生成預覽文件
End If
End Sub

出現「系統找不到路徑」!

ImageObj.Open Trim(Server.MapPath(Imagename))
電腦壞了

熱點內容
雲存儲免費的攝像頭 發布:2024-10-12 00:15:47 瀏覽:620
DA與腳本 發布:2024-10-12 00:14:22 瀏覽:255
如何看配置支不支持黑蘋果 發布:2024-10-12 00:13:45 瀏覽:588
固件怎麼編譯 發布:2024-10-12 00:05:48 瀏覽:90
隨機編譯軌道教學 發布:2024-10-11 23:52:56 瀏覽:412
為什麼人力資源更改密碼還是登錄不了 發布:2024-10-11 23:52:56 瀏覽:468
直線畫中點演算法 發布:2024-10-11 23:52:55 瀏覽:931
帕拉迪堡壘機密碼如何更改 發布:2024-10-11 23:39:58 瀏覽:208
sqlserver期末試題 發布:2024-10-11 23:39:45 瀏覽:599
小度智能音箱如何解除配置 發布:2024-10-11 23:39:06 瀏覽:515