当前位置:首页 » 文件管理 » 上传图片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 是 文件扩展名错误,也就是你上传的文件格式不符合要求,需要先转换为正确格式,然后再上传

热点内容
电信路由器密码设置无线路由器怎么设置密码 发布:2024-05-18 10:55:00 浏览:647
安卓系统是属于哪个国家的手机 发布:2024-05-18 10:41:41 浏览:99
linux运维前景 发布:2024-05-18 10:24:44 浏览:658
c语言crc算法 发布:2024-05-18 09:59:03 浏览:644
linuxc编程视频 发布:2024-05-18 09:55:58 浏览:273
如何建造一个好的服务器 发布:2024-05-18 09:54:30 浏览:524
编译原理中的左结合 发布:2024-05-18 09:42:00 浏览:26
怎样加密路由器 发布:2024-05-18 09:41:55 浏览:605
百度云不能上传视频了 发布:2024-05-18 09:41:08 浏览:148
mac适合买大存储 发布:2024-05-18 08:30:08 浏览:583