如何用SAFileUp上传文件?

2016-01-29 17:28 18 1 收藏

如何用SAFileUp上传文件?,如何用SAFileUp上传文件?

【 tulaoshi.com - ASP 】

  How Do I Upload Files to the database with SAFileUp?  
Don't 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"
      upl.SaveAs "D:MyWebsMyPictures" & NewFileName

'Make sure we have the http:// extension
'remove it if it was already entered then re-add it
      path = NewFileName
      url = replace(url,"http://","")
      url = CStr("http://&quo

来源:https://www.tulaoshi.com/n/20160129/1501554.html

延伸阅读
酷盘PC版如何上传文件   酷盘PC版上传文件的方法如下: 1.首先,安装酷盘PC客户端,注册并登录酷盘。 2.双击桌面的酷盘图标或双击任务栏上的酷盘图标打开酷盘界面。 3.在酷盘界面上点击上传按钮选择文件或文件夹上传至酷盘,也可以直接拖拽我的电脑、我的桌面、资源管理器的文件到酷盘界面进行上传。 4.酷...
如何使用手机微云上传文件?   首先下载手机微云这是傻子都会做的我就不多说了,在使用微云是要把QQ登录,进去QQ找到微云网络文件主页面,插入USB与电脑连接,选择不要传输的文件、图片或其他资料等,点击传输。 就这样会显示连接确认键,点击确认按照提示操作即可,将手机图片之类的上传到电脑等电脑点击接收就行了。微云使...
微云网盘如何上传同步文件?   微云网盘上传同步文件的方法如下: 一、微云PC客户端上传方法: 您通过电脑登录微云PC客户端后,微云会在您的本地电脑中创建一个微云网盘同步文件夹,可点击微云服务界面所提供的微云网盘入口=》打开网盘后,通过本地电脑移动、拖动或复制需要上传同步的文件内容到该文件夹下(D:/微云网盘/***...
天翼云盘如何上传文件?   天翼云是一款由中国电信官方发布的网盘存储服务,用户通过将日常办公中较为重要的资料被分到云盘中,不过一些用户不知道如何上传文件到天翼云,故此小编为大家提供了该方法教程,需要的用户赶快试试吧! 操作方法 1.用户下载安装天翼云PC客户端,如果您没有账号,请注册,已注册的用户直接登录即可...
标签: Web开发
最近在因为在学习Remoting,纯粹只是了解一下,发现Remoting确实是好东西。 我们通常有三种方式来使用remoting,一种是 第一种:Publishing a public object 公开的对象创建在本地 第二种:Remote creation of a public object (SAO) 对象创建在客户端请求中 第三种:Remote creation of a private object (CAO) ...

经验教程

717

收藏

9
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部