如何用SAFileUp上传文件?

2016-01-29 17:28 22 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

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

延伸阅读
标签: 服务器
flashfxp怎么上传文件   flashfxp是很多网站编辑都在使用的FTP管理工具,主要用于文件、网站电脑软件与手机软件的上传。不过,刚刚下载FTP管理工具的网友,可能还不是很清楚flashfxp上传文件该怎么设置,下面就一起来学习一下flashfxp上传文件的教程吧!希望本教程可以帮到大家哦! 1、首先,打开FlashFXP软件; 2、点击站...
标签: Web开发
本文讲解了一个使用XML技术上传文件的例子,使用该方法没有传统方法中的种种限制。 这个例子讲述了如何使用MSXML3.0和ADO Stream对象来实现这种新的上传方法。好处有很多,比如,不需要专用的上传组件。 引言 为了在HTML网页中获得上传功能,在客户端我们可以使用如下格式的FORM: FORM NAME="myForm" ACTION=...
标签: PHP
  文件上传的实现   对ASP比较熟悉的朋友可能知道用ASP上传文件可是不太简单,PHP不同,比较容易,看例子:send.htm和get.php 如下: <!--文件send.htm -- <form ENCTYPE="multipart/form-data" ACTION="get.php" METHOD=post   <INPUT TYPE="hidden" name="MAX...
FlashFXP上传文件教程   1、首先,打开FlashFXP软件 2、点击站点按钮,将网站添加到新的站点 3、站点添加好后,添加连接图标按钮或者双击flashifxp sites下的用户,连接网站。确认网站FTP连接成功。如未连接成功,可根据提示,修改站点设置,确认FTP账号和密码正确,且FTP连接端口,和空间设置的FTP端口 5、确认网站F...
应用宝如何上传文件到手机上?   点击我的手机首页或者工具箱的文件管理,可以管理手机里的文件。 上传文件到手机有两种方式: 1、选择文件管理,点击窗口顶部的上传文件或在文件夹的空白处右键点击上传文件,均可一次性把电脑文件夹上传到手机。 2、在我的手机里各个类别的资源模块点击添加,选择需要添加的文件即...

经验教程

108

收藏

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