Multiimage upload using ASP (2)

Source: Internet
Author: User

Upfile. asp
<! -- # Include file = "Upload. Inc" -->
<HTML>
<Head>
<Title> File Upload </title>
</Head>
<Body>
<%
Dim Arr (3)
Dim upload, file, formname, formpath, icount, filename, fileext, I
Set upload = new upload_5xsoft 'create an upload object

Formpath = upload. Form ("filepath ")
'Add (/) after the Directory (/)
If right (formpath, 1) <> "/" then formpath = formpath &"/"
Icount = 0
I = 0
For each formname in upload. file' list all uploaded files
Set file = upload. File (formname) 'to generate a file object

If file. filesize <0 then
Response. write "<font size = 2> select the image 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> the image size exceeds the limit [<a href = # onclick = history. go (-1)> re-upload </a>] </font>"
Response. End
End if
If fileext <> ". GIF" and fileext <> ". jpg" then
Response. the write "<font size = 2> file format is incorrect [<a href = # onclick = history. go (-1)> re-upload </a>] </font>"
Response. End
End if

Fileext = lcase (right (file. filename, 4 ))
Filename = formpath & year (now) & month (now) & Day (now) & hour (now) & minute (now) & Second (now) & file. filename
Arr (I) = filename
I = I + 1

If file. filesize> 0 then' if filesize> 0, file data exists.
File. saveas server. mappath (filename) 'save the file

'Response. Write File. filepath & file. filename & "(" & file. filesize & ") =>" & formpath & file. filename & "success! <Br>"

Icount = icount + 1
End if
Set file = nothing
Next
If instr (ARR (0 ),". ") = 0 and instr (ARR (1 ),". ") = 0 and instr (ARR (2 ),". ") = 0 then
Response. write "<font size = 2> select the image you want to upload [<a href = # onclick = history. go (-1)> re-upload </a>] </font>"
Response. End
End if
If instr (ARR (0), ".") <> 0 then
Response. Write "<SCRIPT> opener.doc ument. Forms [0]. myface. value = '" & Arr (0) & "' </SCRIPT>"
Else
Response. Write "<SCRIPT> opener.doc ument. Forms [0]. myface. value = '</SCRIPT>"
End if
If instr (ARR (1), ".") <> 0 then
Response. Write "<SCRIPT> opener.doc ument. Forms [0]. myface1.value = '" & Arr (1) & "' </SCRIPT>"
Else
Response. Write "<SCRIPT> opener.doc ument. Forms [0]. myface1.value = '</SCRIPT>"
End if
If instr (ARR (2), ".") <> 0 then
Response. Write "<SCRIPT> opener.doc ument. Forms [0]. myface2.value = '" & Arr (2) & "' </SCRIPT>"
Else
Response. Write "<SCRIPT> opener.doc ument. Forms [0]. myface2.value = '</SCRIPT>"
End if
Set upload = nothing 'Delete this object

Session ("upface") = "done"

Htmend icount & "File Upload is complete! "

Sub htmend (MSG)
Set upload = nothing
Response. write "<HTML> Response. End
End sub
%>
</Body>
</Html>

This article comes from web development network Original article link: http://www.cncms.com.cn/asp/5006_3.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.