當前位置:首頁 » 文件管理 » 上傳圖片file

上傳圖片file

發布時間: 2022-04-16 21:25:01

㈠ 如何上傳圖片

<!--#include file="upload.asp"-->
<%
const upload_type=0 '上傳方法:0=無懼無組件上傳類,1=FSO上傳 2=lyfupload,3=aspupload,4=chinaaspupload

dim upload,file,formName,SavePath,filename,fileExt
dim upNum
dim EnableUpload
dim Forumupload
dim ranNum
dim uploadfiletype
dim msg,founderr
msg=""
founderr=false
EnableUpload=false
SavePath = "../DateBasc/" '存放上傳文件的目錄
if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目錄後加(/)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<%
if EnableUploadFile="No" then
response.write "系統未開放文件上傳功能"
else
if session("admin")="" and session("UserName")="" then
response.Write("請登錄後再使用本功能!")
else
select case upload_type
case 0
call upload_0() '使用化境無組件上傳類
case else
'response.write "本系統未開放插件功能"
'response.end
end select
end if
end if
%>
</body>
</html>
<%
sub upload_0() '使用化境無組件上傳類
set upload=new upload_file '建立上傳對象
for each formName in upload.file '列出所有上傳了的文件
set file=upload.file(formName) '生成一個文件對象
if file.filesize<100 then
msg="請先選擇你要上傳的文件!"
founderr=true
end if
if file.filesize>(MaxFileSize*1024) then
msg="文件大小超過了限制,最大隻能上傳" & CStr(MaxFileSize) & "K的文件!"
founderr=true
end if

fileExt=lcase(file.FileExt)
Forumupload=split(UpFileType,"|")
for i=0 to ubound(Forumupload)
if fileEXT=trim(Forumupload(i)) then
EnableUpload=true
exit for
end if
next
if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then
EnableUpload=false
end if
if EnableUpload=false then
msg="這種文件類型不允許上傳!\n\n只允許上傳這幾種文件類型:" & UpFileType
founderr=true
end if
strJS="<SCRIPT language=javascript>" & vbcrlf
if founderr<>true then
randomize
ranNum=int(900*rnd)+100
FileName=SavePath&upload.form("name")&".xls"

file.SaveToFile Server.mappath(FileName) '保存文件

msg="文件上傳成功!"

end if
strJS=strJS & "alert('" & msg & "');" & vbcrlf
if session("filename")<>"" then
strJS=strJS & "document.location='add_danan.asp','right';" & vbcrlf
else
strJS=strJS & "history.go(-1);" & vbcrlf
end if
strJS=strJS & "</script>"
response.write strJS
next
set upload=nothing
end sub
%>

下面是upload.asp文件
<%
'----------------------------------------------------------------------
'轉發時請保留此聲明信息,這段聲明不並會影響你的速度!
'******************* 無組件上傳類 ********************************
'修改者:梁無懼
'電子郵件:[email protected]
'網站:http://www.25cn.com
'原作者:稻香老農
'原作者網站:http://www.5xsoft.com
'聲明:此上傳類是在化境編程界發布的無組件上傳類的基礎上修改的.
'在與化境編程界無組件上傳類相比,速度快了將近50倍,當上傳4M大小的文件時
'伺服器只需要10秒就可以處理完,是目前最快的無組件上傳程序,當前版本為0.96
'源代碼公開,免費使用,對於商業用途,請與作者聯系
'文件屬性:例如上傳文件為c:\myfile\doc.txt
'FileName 文件名 字元串 "doc.txt"
'FileSize 文件大小 數值 1210
'FileType 文件類型 字元串 "text/plain"
'FileExt 文件擴展名 字元串 "txt"
'FilePath 文件原路徑 字元串 "c:\myfile"
'使用時注意事項:
'由於Scripting.Dictionary區分大小寫,所以在網頁及ASP頁的項目名都要相同的大小
'寫,如果人習慣用大寫或小寫,為了防止出錯的話,可以把
'sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'改為
'(小寫者)sFormName = LCase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
'(大寫者)sFormName = UCase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
'**********************************************************************
'----------------------------------------------------------------------
dim oUpFileStream

Class upload_file

dim Form,File,Version

Private Sub Class_Initialize
'定義變數
dim RequestBinDate,sStart,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
dim iFileSize,sFilePath,sFileType,sFormvalue,sFileName
dim iFindStart,iFindEnd
dim iFormStart,iFormEnd,sFormName
'代碼開始
Version="無組件上傳類 Version 0.96"
set Form = Server.CreateObject("Scripting.Dictionary")
set File = Server.CreateObject("Scripting.Dictionary")
if Request.TotalBytes < 1 then Exit Sub
set tStream = Server.CreateObject("adodb.stream")
set oUpFileStream = Server.CreateObject("adodb.stream")
oUpFileStream.Type = 1
oUpFileStream.Mode = 3
oUpFileStream.Open
oUpFileStream.Write Request.BinaryRead(Request.TotalBytes)
oUpFileStream.Position=0
RequestBinDate = oUpFileStream.Read
iFormEnd = oUpFileStream.Size
bCrLf = chrB(13) & chrB(10)
'取得每個項目之間的分隔符
sStart = MidB(RequestBinDate,1, InStrB(1,RequestBinDate,bCrLf)-1)
iStart = LenB (sStart)
iFormStart = iStart+2
'分解項目
Do
iInfoEnd = InStrB(iFormStart,RequestBinDate,bCrLf & bCrLf)+3
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iFormStart
oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sInfo = tStream.ReadText
'取得表單項目名稱
iFormStart = InStrB(iInfoEnd,RequestBinDate,sStart)-1
iFindStart = InStr(22,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'如果是文件
if InStr (45,sInfo,"filename=""",1) > 0 then
set oFileInfo= new FileInfo
'取得文件屬性
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileName = GetFileName(sFileName)
oFileInfo.FilePath = GetFilePath(sFileName)
oFileInfo.FileExt = GetFileExt(sFileName)
iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr(iFindStart,sInfo,vbCr)
oFileInfo.FileType = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileStart = iInfoEnd
oFileInfo.FileSize = iFormStart -iInfoEnd -2
oFileInfo.FormName = sFormName
file.add sFormName,oFileInfo
else
'如果是表單項目
tStream.Close
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iInfoEnd
oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2
tStream.Position = 0
tStream.Type = 2
tStream.Charset = "gb2312"
sFormvalue = tStream.ReadText
form.Add sFormName,sFormvalue
end if
tStream.Close
iFormStart = iFormStart+iStart+2
'如果到文件尾了就退出
loop until (iFormStart+2) = iFormEnd
RequestBinDate=""
set tStream = nothing
End Sub

Private Sub Class_Terminate
'清除變數及對像
if not Request.TotalBytes<1 then
oUpFileStream.Close
set oUpFileStream =nothing
end if
Form.RemoveAll
File.RemoveAll
set Form=nothing
set File=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 GetFileExt(FullPath)
If FullPath <> "" Then
GetFileExt = mid(FullPath,InStrRev(FullPath, ".")+1)
Else
GetFileExt = ""
End If
End function

End Class

'文件屬性類
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileType,FileStart,FileExt
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
FileType = ""
FileExt = ""
End Sub

'保存文件方法
Public function SaveToFile(FullPath)
dim oFileStream,ErrorChar,i
SaveToFile=1
if trim(fullpath)="" or right(fullpath,1)="/" then exit function
set oFileStream=CreateObject("Adodb.Stream")
oFileStream.Type=1
oFileStream.Mode=3
oFileStream.Open
oUpFileStream.position=FileStart
oUpFileStream.to oFileStream,FileSize
oFileStream.SaveToFile FullPath,2
oFileStream.Close
set oFileStream=nothing
SaveToFile=0
end function
End Class
%>

㈡ 上傳文件時 圖片怎麼上傳

首先你要有網路空間
如果沒有,請點擊右上角你的用戶名,選擇右側的【我的空間】,進行激活。
圖片上傳步驟為:
【步驟一】准備圖片
在上傳圖片前,您需要在電腦上准備好圖片。如果是網上的圖片,需要先將圖片存到電腦上。
操作為將滑鼠移至圖片上,點擊滑鼠右鍵,選擇「圖像另存為」,請記住圖片的存放路徑。
【步驟二】上傳圖片
圖片准備好後,點擊提問頁面或者回答頁面的「上傳圖片」鏈接,在彈出的小窗口中點擊「瀏覽」,選擇圖片後點擊「確定」就可以完成圖片的上傳。
【請注意】
1.二級及以上用戶登錄後可以上傳圖片.
2.您只能上傳本地電腦中的圖片,對於網上的圖片,可以先下載到本地,然後再進行上傳。
3.可上傳的圖片格式將限於JPG、GIF、PNG和BMP,最大為3M。
4.為了保證圖片在頁面的顯示效果,網路知道會自動將圖片進行等比壓縮,所以請盡量選擇長寬相近的圖片。
5.如果圖片與您所提交的內容不相關,將會被刪除。
6.如果等級尚未達到或是需要上傳多張圖片,可以把圖片的鏈接地址發上來,也一樣起到提問的效果。

㈢ 上傳照片顯示file extension error

file
extension
error

文件擴展名錯誤,也就是你上傳的文件格式不符合要求,需要先轉換為正確格式,然後再上傳

㈣ 電腦怎樣上傳圖片文件

一,把數碼相機用USB連接電腦,然後在我的電腦中的可移動磁碟中找到相機的文件夾,把裡面的照片復制或剪切,然後粘貼在你想放置的文檔里.

二,在WORD中打開你的文檔中的文字,然後想在插入圖片的部位按滑鼠,再點插入,點圖片,在文件夾中找出要插入的照片點確定就行了.

您可以用兩種方法上傳照片:單張上傳、打包批量上傳。
(1)登錄相冊並點擊主菜單中的"我的相冊"進入您的相冊列表。
(2)點擊列表右上角的"上傳照片"按鈕,或者從相冊列表中選擇進入某一個相冊後點擊右上角的"上傳照片"按鈕。
(3)選擇好照片或壓縮文件,輸入照片名稱和照片描述等,點擊"上傳"就可以將照片直接上傳,上傳的壓縮文件將由系統在後台解壓縮成單張照片。

注意:(1)網路相冊一般支持您上傳gif、jpg、格式的圖片;
(2)您上傳的照片沒有尺寸限制;
(3)單張照片上傳時,每張照片必須小於1兆,如果是QQ會員,可以上傳不限制大小的照片;
(4)打包批量上傳照片時,目前公支持上傳zip格式的壓縮文件,每個壓縮文件必須小於5兆,壓縮文件里的每張照片不能大於1兆。

㈤ 怎麼用ftp上傳圖片

FTP上傳工具就是通過FTP傳輸協議上傳文件的工具咯,像通過BT協議和HTTP協議一樣,具體如下:

文件傳輸協議
FTP(File Transfer Protocal),是文件傳輸協議的簡稱。用於Internet上的控制文件的雙向傳輸。同時,它也是一個應用程序(Application)。用戶可以通過它把自己的PC機與世界各地所有運行FTP協議的伺服器相連,訪問伺服器上的大量程序和信息。

FTP(File Transfer Protocol)

FTP的作用

正如其名所示:FTP的主要作用,就是讓用戶連接上一個遠程計算機(這些計算機上運行著FTP伺服器程序)察看遠程計算機有哪些文件,然後把文件從遠程計算機上拷到本地計算機,或把本地計算機的文件送到遠程計算機去。

FTP工作原理


通過ftp傳輸文件的一般步驟

1.在本地電腦上登陸到國際互聯網.

2.搜索有文件共享主機或者個人電腦(一般有專門的FTP伺服器網站上公布的,上面有進入該主機或個人電腦的名稱,口令和路徑).

3.當與遠程主機或者對方的個人電腦建立連接後,用對方提供的用戶名和口令登陸到該主機或對方的個人電腦.

4.在遠程主機或對方的個人電腦登陸成功後,就可以上傳你想跟別人分享的東東或者下載別人授權共享的東東(這里的東東是指能放到電腦里去又能在顯示屏上看到的東東).

5.完成工作後關閉FTP下載軟體,切斷連接.

為了實現文件傳輸,用戶還要運行專門的文件傳輸程序,比如網際快車就有這方面的功能,其它還有很多專門的FTP傳輸軟體,FlashFxp為其中的傑出軟體。有興趣的網友可以試試其他的軟體,如LeapFTP總歸各有各的特色.

㈥ 用fileupload上傳圖片,怎麼獲取上傳後圖片的相對路徑

你上傳時不是通過獲取過圖片保存路徑的絕對路徑嗎,比如這樣: String path = thisgetServletContext()getRealPath("/data/userfile/image"); //文件保存路徑 然後你只需要把圖片的文件名再保存在資料庫中,在顯示頁面直接使用相對路徑來指向用fileupload上傳圖片,怎麼獲取上傳後圖片的相對路徑

㈦ 上傳照片顯示file extension error

摘要 file extension error 是 文件擴展名錯誤,也就是你上傳的文件格式不符合要求,需要先轉換為正確格式,然後再上傳

㈧ 如何上傳圖片到圖片伺服器

使用一些已有的組件幫助我們實現這種上傳功能。 常用的上傳組件: Apache 的 Commons FileUpload JavaZoom的UploadBean jspSmartUpload 以下,以FileUpload為例講解 1、在jsp端 <form id="form1" name="form1" method="post" action="servlet/fileServlet" enctype="multipart/form-data"> 要注意enctype="multipart/form-data" 然後只需要放置一個file控制項,並執行submit操作即可 <input name="file" type="file" size="20" > <input type="submit" name="submit" value="提交" > 2、web端 核心代碼如下: public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); DiskFileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List items = upload.parseRequest(request); Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); if (item.isFormField()) { System.out.println("表單參數名:" + item.getFieldName() + ",表單參數值:" + item.getString("UTF-8")); } else { if (item.getName() != null && !item.getName().equals("")) { System.out.println("上傳文件的大小:" + item.getSize()); System.out.println("上傳文件的類型:" + item.getContentType()); System.out.println("上傳文件的名稱:" + item.getName()); File tempFile = new File(item.getName()); File file = new File(sc.getRealPath("/") + savePath, tempFile.getName()); item.write(file); request.setAttribute("upload.message", "上傳文件成功!"); }else{ request.setAttribute("upload.message", "沒有選擇上傳文件!"); } } } }catch(FileUploadException e){ e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); request.setAttribute("upload.message", "上傳文件失敗!"); } request.getRequestDispatcher("/uploadResult.jsp").forward(request, response); }

㈨ file怎樣上傳圖片到伺服器

首先把XML文件的內容存到資料庫裡面的某個表
SqlCommand com=new SqlCommand("select * from 表");
com.Commtype=Commtype.text;
然後把SqlCommand傳遞給WebService
因為對方的webservice介面是需要使用POST方式調用的,然後告訴我POST參數是Command,但是我不是很理解這個Command指的是什麼。其他也沒有說明,就只有一個介面接入地址和數據格式。

㈩ 為什麼在手機上上傳照片顯示file extension error

file extension error 是 文件擴展名錯誤,也就是你上傳的文件格式不符合要求,需要先轉換為正確格式,然後再上傳

熱點內容
七日殺伺服器ip怎麼設置 發布:2024-05-04 11:57:57 瀏覽:429
啟用java 發布:2024-05-04 11:51:46 瀏覽:968
mac下開發php 發布:2024-05-04 11:28:53 瀏覽:627
java介面及實現方法 發布:2024-05-04 11:05:08 瀏覽:566
iphone怎麼清理應用緩存 發布:2024-05-04 11:05:02 瀏覽:409
rest上傳文件 發布:2024-05-04 11:03:19 瀏覽:281
情侶玩游戲解壓視頻 發布:2024-05-04 11:00:57 瀏覽:778
c文件夾大小 發布:2024-05-04 10:54:35 瀏覽:677
回憶源碼 發布:2024-05-04 10:28:20 瀏覽:235
mmm源碼 發布:2024-05-04 09:57:29 瀏覽:262