如何用SAFileUp上传文件?
程序员文章站
2022-07-03 14:05:23
how do i upload files to the database with safileup? dont do it! use safileup t...
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"
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"
推荐阅读
-
如何用SAFileUp上传文件?
-
如何用PHP实现文件上传例子_PHP
-
如何用PHP实现文件上传例子_PHP
-
javascript - ajax结合html5中的file实现文件上传,后台用PHP接收,该如何用PHP接收传过来的formData?
-
如何用纯html实现一个所有浏览器都一样的上传文件按钮
-
post - 如何用curl命令上传文件到制定的目录?后台用php程序来接收,apache httpd做服务器
-
如何用正则完成表单验证和文件上传验证
-
post - 如何用curl命令上传文件到制定的目录?后台用php程序来接收,apache httpd做服务器
-
如何用正则完成表单验证和文件上传验证
-
如何用nodeJs向别的服务器上传文件发送formData数据?