当前位置: 移动技术网 > IT编程>开发语言>.net > 如何用SAFileUp上传文件?

如何用SAFileUp上传文件?

2019年01月12日  | 移动技术网IT编程  | 我要评论

国家公敌下载,cz6131,中外励志故事

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.. 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:  https:// </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"

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网