'---- file name /handld_upload.asp
1 Option Explicit
1
2Response.Expires=0
3Response.Buffer = TRUE
4Response.Clear
5Const IMAGE_SIZE = "width=""200"" height=""150"""
6Dim UploadRequest
7Set UploadRequest = Server.CreateObject("Scripting.Dictionary")
8
9Dim byteCount, RequestBin
10byteCount = Request.TotalBytes
11RequestBin = Request.BinaryRead(byteCount)
12
13BuildUploadRequest RequestBin
14
15Dim saveURL, goURL, filepathname, value, filename
16'---- save path
17'saveURL = UploadRequest.Item("saveURL").Item("Value")
18saveURL = "/"
19
20'---- jump to file path when finish upload
21goURL = UploadRequest.Item("goURL").Item("Value")
22
23filepathname = UploadRequest.Item("my_file").Item("FilePathName")
24value = UploadRequest.Item("my_file").Item("Value")
25filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
26
27'---- debug
28'Response.Write saveURL&"**"&goURL&"**"&filepathname
29'Response.Write "**"&filename
30'Response.End
31
32Dim fso, MyFile, i
33Set fso = Server.CreateObject("Scripting.FileSystemObject")
34If NOT fso.FolderExists(Server.mappath(saveURL) & "\") Then
35RecMkDir(Server.mappath(saveURL) & "\")
36End If
37Set MyFile = fso.CreateTextFile(Server.mappath(saveURL) & "\" & filename)
38
39For i = 1 to LenB(value)
40MyFile.Write chr(AscB(MidB(value,i,1)))
41Next
42
43MyFile.Close
44
45Session("StoredFile") = filename
46Session("strImage") = "
<img "="" &="" border="1" bordercolor="#0000FF" image_size="" src='" & saveURL & filename & "'/>
1"
2
3Response.Redirect goURL
'---- file name /test.asp/
1 Option Explicit
1
2On Error Resume Next
3Response.Expires = 0
4Response.AddHeader "Pragma", "no-cache"
5
6Dim thisFile
7thisFile = Right(Request.ServerVariables("PATH_INFO"),Len(Request.ServerVariables("PATH_INFO"))-InStrRev(Request.ServerVariables("PATH_INFO"), "/"))
8
9If Request("imageCancel") <> "" Then
10Session("StoredFile") = ""
11Session("strImage") = ""
12End If
1<html>
2<head>
3<title>Corp2Net.com</title>
4<script language="JavaScript" src="/admin.js"></script>
5<script language="JavaScript">
6<!--
7function UpLoad(obj)
8{
9if (obj.my_file.value.length < 7)
10return false;
11return true;
12}
13// -->
14</script>
15<body =="" ```="" alink="```" bgcolor="```" color_al_1="" color_bg_1="" color_nl_1="" color_vl_1="" link="```" vlink="```">
16<font color="```
17= C_WD_CONTENT_4
18```">
19Only upload <b>*.jpg</b> or <b>*.gif</b> file!
20<br/>
21Otherwise, image may not show correctly!
22</font>
23<center>
24<table>
If ( Len(Session("strImage")) > 0 ) Then
1<tr>
2<td>
3<table ```="" border="1" bordercolor="```
4= C_WD_T_BORDER
5```" cellpadding="0" cellspacing="0">
6<tr>
7<td>```
8= Session("strImage")
9```</td>
10</tr>
11</table>
12</td>
13</tr>
Else
1<tr>
2<td>
3<table border="1" bordercolor="```
4= C_WD_T_BORDER
5```" cellpadding="0" cellspacing="0">
6<tr>
7<td align="center" valign="top">
8<table ```="" border="0" cellpadding="0" cellspacing="0">
9<tr>
10<td colspan="2"><font class="e-foot" color="```
11= C_WD_CONTENT_4
12```"><b>Upload / preview image:</b></font></td>
13</tr>
14<tr>
15<td colspan="2"> </td>
16</tr>
17<tr>
18<td nowrap="" valign="top"><font class="e-foot" color="```
19= C_WD_CONTENT_4
20```"><b>Step 1:</b></font></td>
21<td valign="top"><font class="e-foot" color="```
22= C_WD_CONTENT_4
23```">Prepare an image with 72 dpi resolution.</font></td>
24</tr>
25<tr>
26<td valign="top"><font class="e-foot" color="```
27= C_WD_CONTENT_4
28```"><b>Step 2:</b></font></td>
29<td valign="top"><font class="e-foot" color="```
30= C_WD_CONTENT_4
31```">Select your image file</font></td>
32</tr>
33<tr>
34<td valign="top"><font class="e-foot" color="```
35= C_WD_CONTENT_4
36```"><b>Step 3:</b></font></td>
37<td valign="top"><font class="e-foot" color="```
38= C_WD_CONTENT_4
39```">Press "Upload" button</font></td>
40</tr>
41<tr>
42<td valign="top"><font class="e-foot" color="```
43= C_WD_CONTENT_4
44```"><b>Step 4:</b></font></td>
45<td valign="top"><font class="e-foot" color="```
46= C_WD_CONTENT_4
47```">Continue <b>OR</b> repeat <b>Step 1-3</b> to change the image</font></td>
48</tr>
49</table>
50</td>
51</tr>
52</table>
53</td>
54</tr>
End If
1</table>
2</center>
3<form action="handle_upload.asp" enctype="multipart/form-data" id="form1" method="POST" name="form1" onsubmit="return UpLoad(this)">
4<input name="saveURL" type="hidden" value="```
5= WEB_TEMP_PATH
6```"/>
7<input ```"="" name="goURL" path_info")="" type="hidden" value="```
8= Request.ServerVariables("/>
9<input class="btn" name="my_file" type="file"/>
10<input class="btn" name="submit" type="submit" value="Upload"/>
11</form>
12<form action="```
13= thisFile
14```" id="form2" name="form2">
15<input class="btn" name="imageCancel" type="submit" value="Press Here To Cancel Image!"/>
16<br/> <br/>
17<input class="btn" id="submit1" name="submit1" onclick="window.opener.focus();window.close();" type="submit" value="Finish!"/>
18</form>
19</body>
20</head></html>