Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ASP 3.0 : Server.MapPath(), ASP 0171 (0x80004005) Signup · Login
Author Thread
Server.MapPath(), ASP 0171 (0x80004005)
Posted in tutorial: Uploading Files to the Server Hard Disk using plain ASP
·  ahmad
User
Joined: 24 Aug 2005
Total Posts: 5
Server.MapPath(), ASP 0171 (0x80004005)
Posted: 24 Aug 2005
Function OpenUploadRS()
Dim RS : Set RS = CreateObject("ADODB.Recordset")

'Open dynamic recordset, table Upload
RS.Open "ListFiles", GetConnection, 2, 2

Set OpenUploadRS = RS
end Function

Function GetConnection()
dim Conn: Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.open "Data Source=" & Server.MapPath("upload.mdb")
set GetConnection = Conn
end function

Function SplitFileName(FullPath)
Dim Pos, PosF
PosF = 0
For Pos = Len(FullPath) To 1 Step -1
Select Case Mid(FullPath, Pos, 1)
Case ":", "/", "\": PosF = Pos + 1: Pos = 0
End Select
Next
If PosF = 0 Then PosF = 1
SplitFileName = PosF
End Function

Function GetPath(FullPath)
GetPath = left(FullPath, SplitFileName(FullPath)-1)
End Function


'{b}get an unique upload ID for this upload script and progress bar.
Dim UploadID, PostURL
UploadID = Form.NewUploadID

'Send this ID as a UploadID QueryString parameter to this script.
PostURL = Request.ServerVariables("SCRIPT_NAME") & "?UploadID=" & UploadID'{/b}

%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<TABLE cellSpacing=2 cellPadding=1 width="90%" bgColor=white border=0>
<TR>
<TD height="59" colSpan=2><form name="file_upload" method="POST" ENCTYPE="multipart/form-data" OnSubmit="return ProgressBar();" Action="<%=PostURL%>">

<Div ID=files>
File 1 : <input type="file" name="File1"> Description 1 :
<Input Name="Desc-File1" Size=50>
<br>
File 2 : <input type="file" name="File2"> Description 2 :
<Input Name="Desc-File2" Size=50>
<br>
File 3 : <input type="file" name="File3"> Description 3 :
<Input Name="Desc-File3" Size=50>

</Div>

<Input Type=Button Value="Add a file" OnClick=return(Expand())
Style="border=0;background=yellow;cursor:hand"><br>


<input Name=SubmitButton Value="Submit »" Type=Submit><br>
</Form></TD>
</TR>
<TR>
<TD height="59" colSpan=2> <P>      </P>
 <font color="#FFFFFF"><%=Form.SizeLimit%>(<%=Form.SizeLimit \ 1024 %></font></TD>
</TR>
</TABLE>

<SCRIPT>
//Open window with progress bar.
function ProgressBar(){
var ProgressURL
ProgressURL = 'progress.asp?UploadID=<%=UploadID%>'

var v = window.open(ProgressURL,'_blank','toolbar=no,locat ion=no,directories=no,status=no,menubar=no,scrollb ars=no,resizable=yes,width=350,height=200')

return true;
}
</SCRIPT>

<Script>
//Expand form with a new File fields if needed.
var nfiles = 3;
function Expand(){
nfiles++
var adh = '<BR> File '+nfiles+' : <input type="file" name="File'+nfiles+'"> Description '+nfiles+' : <Input Name="Desc-File'+nfiles+'" Size=50>';
files.insertAdjacentHTML('BeforeEnd',adh);
return false;
}
</Script>
</body>
</html>

Users Who Have Visited This Thread In Last 24 Hours
3 Visitors

Login
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.