Upload | data | database on image upload examples on the internet there are a lot of articles and the original code. But every time on the forum to browse the post is to see a lot of users of the picture upload headache and trouble. In fact, this problem has also made me feel a headache. Also read a lot of articles and code. Now I write this article is to my favorite piece of code and dynamic Network master of this code optimization, plus I add some code together! Oh, in fact this article is stained with the writing of this Code people (Tao Xiang) and move the net of those masters of Light. :)
Well, don't talk nonsense. Start to build the required environment and data structure!
First create a new folder named photo. (I'm here to upload the picture to this folder.) ) to create a database of names called databases. Then set up a table named Sfile. Interior and exterior design four fields are ID (int), image (varchar), image1 (varchar), image2 (varchar). The database I use here is SQL.
Related files
Register.asp
<title> Documents </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<form name= "Form1" method= "Post" action= "save.asp" >
<table width= "50%" border= "1" cellspacing= "0" cellpadding= "0" align= "center" >
<tr>
<TD width= "20%" ><a href= "onclick=" Javascript:window.open ('/reg_upload.asp ', null, ' left=40%,top=40%, Height=250,width=470,status=yes,toolbar=no,menubar=no,resizable=yes,copyhistory=yes,scrollbars=yes,location=no , Status=no,titlebar=no ') > Picture upload </a></td>
<TD width= "80%" >
<input type= "text" name= "Myface" >
<input type= "text" name= "Myface1" >
<input type= "text" name= "Myface2" >
(Users do not need to fill in the picture upload automatically generated) </td>
</tr>
<tr>
<TD colspan= "2" align= "Center" >
<input type= "Submit" name= "Submission" value= "submitted" >
<input type= "reset" name= "Submit2" value= "reset" >
</td>
</tr>
</table>
</form>
</body>
Reg_upload.asp
<title></title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link rel= "stylesheet" href= "Css/style.css" type= "Text/css" >
<body leftmargin= "0" topmargin= "0" >
<br>
<br>
<br>
<table width= "90%" border= "0" align= "center" bgcolor= "#000000" height= "152" cellspacing= "1" >
<tr>
<TD height= "align=" "Center" bgcolor= "#FFFFFF" ><font color= "#FFFF33" ><b><font size= "4" color= "#000000" > Choose pictures </font></b></font></td>
</tr>
<tr>
<TD bgcolor= "#FFFFFF" >
<form name= "form" method= "POST" action= "upfile.asp" enctype= "Multipart/form-data" >
<input type= "hidden" name= "filepath" value= "Photo" >
<input type= "hidden" name= "act" value= "upload" >
<input type= "File" Name= "File1" size= "><br>"
<input type= "File" Name= "File2" size= "><br>"
<input type= "File" Name= "File3" size= ">"
<input type= "Submit" name= "Submit" value= "paste" class= "TL" >
</form>
</td>
</tr>
</table>
</body>
Upfile.asp
<!--#include file= "Upload.inc"-->
<title> File Upload </title>
<body>
<%
Dim arr (3)
Dim upload,file,formname,formpath,icount,filename,fileext,i
Set upload=new upload_5xsoft ' Build upload Object
Formpath=upload.form ("filepath")
"Add (/) to the directory
If Right (formpath,1) <> "/" Then formpath=formpath& "/"
Icount=0
I=0
For every formName in Upload.file ' lists all uploaded files
Set File=upload.file (formName) ' generates a File object
If File.filesize<0 Then
Response.Write "<font size=2> please first select the pictures you want to upload [<a href=# onclick=history.go ( -1) > re-upload </a>]</font> "
Response.End
End If
If file.filesize>100000 Then
Response.Write "<font size=2> picture size exceeds limit [<a href=# onclick=h