您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

如何用SAFileUp上传文件?

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 18:14 点击:
How Do I Upload Files to the database with SAFileUp?  
Dont do it! Use SAFileUp to upload the files to the server but do not store the image in the database. Instead store the path to the file. Better yet if the images will sit in the same folder just store the actual file name. Uploading the entire image to the database wastes too many resources. You need to upload the image in binary format which is slow. You also waste all that extra database space to store the image. Then you lose speed retrieving it.

These are the requirements for uploading files with SAFileup.
1] You need SAFileUp installed on the server. 2] You need Read, Write, and Change permissions on the directory you are going to save the pictures to. In my example I named the folder "Mypictures". Contact your ISP to set this up for you.
This is the web form - upload.asp. Notice the multipart/form-data. We are not just uploading text here. We are pulling files from the hard drive. Special rules and instructions apply. INPUT TYPE="file" gives us the browser button on the screen which lets us access(小型网站之最爱) the hard drive.
<TABLE><TR>
<TD valign=top>
Category
</TD>
<TD>
<form enctype="multipart/form-data" method="post"  action="upload2.asp">
<INPUT TYPE="text"  NAME="categoryname">
</TD>
</TR>
<TR><TD align="right">
Alternate Text for banner:</TD>
<TD><INPUT TYPE="text"  NAME="alt">
</TD></TR>
<TR><TD align="right">
URL:  http:// </TD><TD><INPUT TYPE="text"  NAME="url">
</TD></TR>
<TR><TD align="right">
Get Add:</TD><TD><input type="file" name="f1"><br>
</TD></TR></TABLE>      
<BR><BR>
      <input type="submit"  NAME="submit"  value="submit">
</form>




The FORM Processing script - upload2.asp. Notice the upl.form("FORM_NAME"). you cannot use request.form to
retrieve form data when uploading files. You must reference the form elements with the File Upload object.
In this example it is "upl". <%
You must have SAFileUp installed on the server
      Set upl = Server.CreateObject("SoftArtisans.FileUp")

      categoryname = trim(replace(upl.form("categoryname"),"",""))
      alt = trim(replace(upl.form("alt"),"",""))
      url = trim(replace(upl.form("url"),"",""))

if categoryname = "" then
      response.write "You Must Enter a category name"
      response.end
End IF

NewFileName = Mid(upl.UserFilename, InstrRev(upl.UserFilename, "") + 1)

Rename file if file name already exists
      upl.CreateNewFile = true

Do not overwrite existing files
The folder the pictures will be saved in need Read, Write
and Change permissions.  In this example it is "MyPictures"

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • WAP常见问题问答大全(四)
      • ASP开发必备:WEB打印代码大全
      • ASP调用系统ping命令
      • asp缓存技术
      • ASP教程:第三篇 ASP基础
      • 用ASP+XML打造留言本(4)
      • 关于ASP Recordset 分页出现负数解决方法及建议
      • 用asp怎样编写文档搜索页面(5)
      • ASP处理多关键词查询实例代码
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1