File Upload question

C

csleimbach

I am having trouble with uploading a file to a website. I can not figure
what I am doing wrong. I have a .asp file that you put a username and
password in that is connected to a database. One of the buttons you push is
"Add Press Releasses". It prompts you to choose your file and when you
select the upload button it just refreshes. Here is the code:

this part works:
Dim Stage
Dim Count, i
Dim Action
Action=Request.Form("Action")
Dim AdminCon:set AdminCon=Server.CreateObject("ADODB.Connection")
AdminCon.Provider = "Microsoft.Jet.OLEDB.4.0"
AdminCon.Open Server.MapPath("databasename.mdb")
Dim rs:set rs=Server.CreateObject("ADODB.Recordset")
Response.Write("<form name=Subscribe action=AdminPress.asp
method=post>")
Dim HostPath
HostPath = "http://" & Request.ServerVariables("SERVER_NAME") &
Left(Request.ServerVariables("PATH_INFO"), Instr(1,
Request.ServerVariables("PATH_INFO"), "adminpress.asp", 1) - 1)
CodeFile="UploadPressRelease.aspx.vb"
Inherits="System.Web.UI.Page"
Stage=Request.Form("Pass")
if Len(Stage)=0 then
Response.Write("<table>")
Response.Write("<tr><td>")
Response.Write("User:</td><td>")
Response.Write("<input id=User name=UserText style=""width: 150px""
type=""text"" /><br />")
Response.Write("</td></tr>")
Response.Write("<tr><td>")
Response.Write("Password:</td><td>")
Response.Write("<input id=Pass name=Pass style=""width: 150px""
type=""password"" />")
Response.Write("</td></tr>")
Response.Write("<tr><td></td><td>")
Response.Write("<input type=submit name=Login value=Login />")
Response.Write("</td></tr>")
Response.Write("</table>")
else
Dim User
User=Request.Form("UserText")
set rs = AdminCon.Execute("Select * from admin")
rs.Filter = "User='" & User & "' and Password='" & Stage & "'"
if rs.EOF then
Response.Write("User/Password not found")
Response.Write("<input type=submit name=TryAgain value=""Try
Again"" />")
else
Response.Write("<input type=hidden name=""UserText"" Value=" &
User & " />")
Response.Write("<input type=hidden name=""Pass"" Value=" & Stage
& " />")
Response.Write("<input type=submit name=""Action"" value=""Add
Press Releases Test"" />")

HERE IS THE PART THAT IS NOT WORKING:
if Action="Add Press Releases Test" then
Dim UpPathtest
Dim UpNametest
UpPathtest = "/lol"
response.Write "<UpNametest = Dir(UpPathtest, vbDirectory)>"
dim filename
dim filefield
response.Write
"<FileName.InnerHtml=FileField.PostedFile.FileName>"
response.Write "<UploadDetails.Visible = True>"
Dim strFileName
response.Write "<strFileName = FileField.PostedFile.FileName>"
Dim c
response.Write "<form id=formFileUploadtest method=post
enctype=Multipart/Form-Data runat=Server>"
response.Write "<b>File Upload In ASP.Net</b>"
response.Write "<hr />"
response.Write "<br />"
response.Write "Choose Your File To Upload : <br />"
response.Write "<input id=FileField type=File runat=server
size=60 /><br />"
response.Write "<br />"
response.Write "<Button ID=UploadButtontest runat=server
Text=Go /></button><br />"
response.Write "<div id=UploadDetails visible=true
runat=server>"
response.Write "File Name: <span id=FileName
runat=server/> <br />"
response.Write "File Content: <span id=FileContent
runat=server/><br />"
response.Write "File Size: <span id=FileSize
runat=server/>bytes<br />"
response.Write "</div>"
response.Write "<c =
System.IO.Path.GetFileName(strFileName)>"
response.Write "<Try>"
response.write"<FileField.PostedFile.SaveAs(\lollaf\ +
c)>"
response.Write "<Span1.InnerHtml = File Uploaded
Sucessfully.>"
response.Write "<Catch Exp As Exception>"
response.Write "<Span1.InnerHtml = Some Error occured.>"
response.Write "<UploadDetails.Visible = False>"
response.Write "<End Try>"
response.Write "<span ID=Span1 style=Color:Red runat=Server/>"
response.Write "</form>"
end if
end if
set rs=Nothing
end if

Yes I am new to all of this.

Thank you for your help in advance.
s
 
G

Guest

I am having trouble with uploading a file to a website.  I can not figure
what I am doing wrong.  I have a .asp file that you put a username and
password in that is connected to a database.  One of the buttons you push is
"Add Press Releasses".  It prompts you to choose your file and when you
select the upload button it just refreshes.  Here is the code:

this part works:
Dim Stage
    Dim Count, i
    Dim Action
    Action=Request.Form("Action")
    Dim AdminCon:set AdminCon=Server.CreateObject("ADODB.Connection")
        AdminCon.Provider = "Microsoft.Jet.OLEDB.4.0"
        AdminCon.Open Server.MapPath("databasename.mdb")
    Dim rs:set rs=Server.CreateObject("ADODB.Recordset")
    Response.Write("<form name=Subscribe action=AdminPress.asp
method=post>")    
    Dim HostPath
    HostPath = "http://" & Request.ServerVariables("SERVER_NAME") &
Left(Request.ServerVariables("PATH_INFO"), Instr(1,
Request.ServerVariables("PATH_INFO"), "adminpress.asp", 1) - 1)
     CodeFile="UploadPressRelease.aspx.vb"
     Inherits="System.Web.UI.Page"
Stage=Request.Form("Pass")
    if Len(Stage)=0 then
        Response.Write("<table>")
        Response.Write("<tr><td>")
        Response.Write("User:</td><td>")
        Response.Write("<input id=User name=UserText style=""width: 150px""
type=""text"" /><br />")
        Response.Write("</td></tr>")
        Response.Write("<tr><td>")
        Response.Write("Password:</td><td>")
        Response.Write("<input id=Pass name=Pass style=""width: 150px""
type=""password"" />")
        Response.Write("</td></tr>")
        Response.Write("<tr><td></td><td>")
        Response.Write("<input type=submit name=Login value=Login />")
        Response.Write("</td></tr>")
        Response.Write("</table>")
    else
        Dim User
        User=Request.Form("UserText")
        set rs = AdminCon.Execute("Select * from admin")
        rs.Filter = "User='" & User & "' and Password='" & Stage & "'"
        if rs.EOF then
            Response.Write("User/Password not found")
            Response.Write("<input type=submit name=TryAgain value=""Try
Again"" />")
        else
            Response.Write("<input type=hidden name=""UserText"" Value=" &
User & " />")
            Response.Write("<input type=hidden name=""Pass"" Value=" & Stage
& " />")
            Response.Write("<input type=submit name=""Action"" value=""Add
Press Releases Test"" />")

HERE IS THE PART THAT IS NOT WORKING:
if Action="Add Press Releases Test" then
               Dim UpPathtest
               Dim UpNametest
               UpPathtest = "/lol"
               response.Write "<UpNametest = Dir(UpPathtest, vbDirectory)>"
               dim filename
               dim filefield
               response.Write
"<FileName.InnerHtml=FileField.PostedFile.FileName>"
               response.Write "<UploadDetails.Visible = True>"
               Dim strFileName
               response.Write "<strFileName = FileField.PostedFile.FileName>"
               Dim c
               response.Write "<form id=formFileUploadtest method=post  
enctype=Multipart/Form-Data runat=Server>"
                response.Write "<b>File Upload In ASP.Net</b>"
                response.Write "<hr />"
                response.Write "<br />"
                response.Write "Choose Your File  To Upload : <br />"
                response.Write "<input id=FileField type=File runat=server
size=60 /><br />"
                response.Write "<br />"
                response.Write "<Button ID=UploadButtontest runat=server
Text=Go /></button><br />"
                    response.Write "<div id=UploadDetails visible=true
runat=server>"
                        response.Write "File Name: <span id=FileName
runat=server/> <br />"
                        response.Write "File Content: <span id=FileContent
runat=server/><br />"
                        response.Write "File Size: <span id=FileSize
runat=server/>bytes<br />"
                response.Write "</div>"
                response.Write "<c  =
System.IO.Path.GetFileName(strFileName)>"
                response.Write "<Try>"
                    response.write"<FileField.PostedFile.SaveAs(\lollaf\ +
c)>"
                    response.Write "<Span1.InnerHtml = File Uploaded
Sucessfully.>"
                    response.Write "<Catch Exp As Exception>"
            response.Write "<Span1.InnerHtml = Some Error occured.>"
            response.Write "<UploadDetails.Visible = False>"
                    response.Write "<End Try>"
                response.Write "<span ID=Span1 style=Color:Red runat=Server/>"
                response.Write "</form>"
            end if
        end if
        set rs=Nothing
    end if

Yes I am new to all of this.

Thank you for your help in advance.
s

Is there any specific error? The part that is not working is quite
big :)
 
C

csleimbach

There is no error. When I push the upload button the file does not upload.
I must be missing something.

Thank you for helping me.

Stacy
 
G

Guest

There is no error.  When I push the upload button the file does not upload.  
I must be missing something.

Thank you for helping me.

Stacy






- Show quoted text -

I'm not sure what you want to achieve with the code, you definitely
should check the final html you send to the browser. From what I can
see is there are two <form> tags, and one is not closed

<form name=Subscribe action=AdminPress.asp
...
<form id=formFileUploadtest method=post
...
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top