Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26378882
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: 系统运维

2009-01-01 16:45:26

1.为了以后能够方便使用上传我现在将所有可能的方法及最好的方法拿出来做成专题供大家使用!
我想:气死我了!
在网上找了近几个小时居然没有一个是系统的介绍一下如何来做组件上传ASP。
所以说我一定要总结出来一起学习分享!
OK,我这次是用ASP中的一个上传组件来做的。
第一步:注册我们的上传组件
regsvr32  这个是WIN自身的注册命令直接 调用 就OK !
第二步:写一个表单提交的页面代码如下:

   

   
    
   

注意了表单中加上了一个enctype哦!
第三步:写服务器端的load.asp文件
<%
DIM saveMapPath,ContentTpye,MaxBytes,ShortFilename
'建立上传组件对象
Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
'获取表单中提交的数据方法(oFileUp.Form("up"))
if isobject(oFileUp.Form("up1"))=true then
    response.Write("The First Step"&"
"&"")
    ContentTpye = trim(oFileUp.Form("up1").contentType)
    response.Write(ContentTpye)
    ShortFilename = oFileUp.Form("up1").ShortFilename
    'MaxBytes = oFileUp.Form("up"&i&"").MaxBytes
    MaxBytes = 200*1024
    if ContentTpye<>"image/x-png" and  ContentTpye<>"image/gif" and ContentTpye<>"image/bmp" and ContentTpye<>"image/pjpeg" and ContentTpye<>"image/jpeg" then
        response.Write "文件类型不正确[只能是.bmp,.jpg,jpeg,.gif,.png格式]"
        oFileUp.Flush
        response.End
    end if
    if oFileUp.Form("up1").TotalBytes > MaxBytes then
        response.Write "文件超过200KB不能上传!"
        oFileUp.Flush
        response.End
    end if
        small=now()
        small=hour(small)&minute(small)&second(small)&cstr(fix(rnd*10000))
        small=small& Right(ShortFilename,4)
        response.Write("test:"+small)
        '确定上传到的目录
        saveMapPath=server.MapPath("/aspUpload/imags/"&small&"")
        '开始上传
        oFileUp.Form("up1").SaveAs saveMapPath
        response.Write "保存成功"
    end if
oFileUp.Flush
%>
搞定!
OK,我一开始调试上面这段的代码的时候总是会报这个错误:

SoftArtisans.SAFile.1 错误 '80070003'

Error occurred when moving cached file to final destination. Error: 3 Please check the NTFS permissions for the directory "C:\WINDOWS\TEMP\" and the directory containing the file "E:\FirstWaiBao\MyPro\imags\164137055.gif". These directories require Read, Write and Delete permissions by the anonymous user ( NT account: IUSR_computername ) and/or by your authenticated users.系统找不到指定的路径。

大家看看这个错误啊!我上CSDN上面看到一个同胞也遇到了这个问题。居然没有人回答他。

写出来共享:

请检查一下E:\FirstWaiBao\MyPro\imags\164137055.gif 这个目录是否你自己建立 了啊!

如果没有的话那说明是他找不到目录当然会报错了。所以人家才提示 没有写文件权限啊哈哈

明白了,终于明白了一个问题啊!天空好美

哦对了,因为我们只是将图片的目录插到数据库中的所以还要插入到数据库的哦!

提取表单数据的话可以用:oFileUp.Form("up") 哈哈!




阅读(551) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~