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("
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("
")
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("
Again"" />")
else
Response.Write("")
Response.Write("")
Response.Write("
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 ""
dim filename
dim filefield
response.Write
""
response.Write ""
Dim strFileName
response.Write ""
Dim c
response.Write "
enctype=Multipart/Form-Data runat=Server>"
response.Write "File Upload In ASP.Net"
response.Write ""
response.Write " "
response.Write "Choose Your File To Upload : "
response.Write "
size=60 /> "
response.Write " "
response.Write "
Text=Go /> "
response.Write "
runat=server>"
response.Write "File Name:
runat=server/> "
response.Write "File Content:
runat=server/> "
response.Write "File Size:
runat=server/>bytes "
response.Write ""
response.Write "
System.IO.Path.GetFileName(strFileName)>"
response.Write ""
response.write"
c)>"
response.Write "
Sucessfully.>"
response.Write ""
response.Write ""
response.Write ""
response.Write ""
response.Write ""
response.Write ""
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
Re: File Upload question
am 21.04.2008 11:57:53 von lexa
On Apr 21, 5:52=A0am, csleimbach
wrote:
> I am having trouble with uploading a file to a website. =A0I can not figur=
e
> what I am doing wrong. =A0I have a .asp file that you put a username and
> password in that is connected to a database. =A0One of the buttons you pus=
h is
> "Add Press Releasses". =A0It prompts you to choose your file and when you
> select the upload button it just refreshes. =A0Here is the code:
>
> this part works:
> Dim Stage
> =A0 =A0 Dim Count, i
> =A0 =A0 Dim Action
> =A0 =A0 Action=3DRequest.Form("Action")
> =A0 =A0 Dim AdminCon:set AdminCon=3DServer.CreateObject("ADODB.Connection"=
)
> =A0 =A0 =A0 =A0 AdminCon.Provider =3D "Microsoft.Jet.OLEDB.4.0"
> =A0 =A0 =A0 =A0 AdminCon.Open Server.MapPath("databasename.mdb")
> =A0 =A0 Dim rs:set rs=3DServer.CreateObject("ADODB.Recordset")
> =A0 =A0 Response.Write("
> method=3Dpost>") =A0 =A0
> =A0 =A0 Dim HostPath
> =A0 =A0 HostPath =3D "http://" & Request.ServerVariables("SERVER_NAME") &
> Left(Request.ServerVariables("PATH_INFO"), Instr(1,
> Request.ServerVariables("PATH_INFO"), "adminpress.asp", 1) - 1)
> =A0 =A0 =A0CodeFile=3D"UploadPressRelease.aspx.vb"
> =A0 =A0 =A0Inherits=3D"System.Web.UI.Page"
> Stage=3DRequest.Form("Pass")
> =A0 =A0 if Len(Stage)=3D0 then
> =A0 =A0 =A0 =A0 Response.Write("
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 response.Write ""
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 response.Write "
olor:Red runat=3DServer/>"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 response.Write ""
> =A0 =A0 =A0 =A0 =A0 =A0 end if
> =A0 =A0 =A0 =A0 end if
> =A0 =A0 =A0 =A0 set rs=3DNothing
> =A0 =A0 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 :-)
Re: File Upload question
am 21.04.2008 14:54:01 von 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
"Alexey Smirnov" wrote:
> On Apr 21, 5:52 am, csleimbach
> wrote:
> > 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("
> > 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("
")
> > 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("
> > Again"" />")
> > else
> > Response.Write("")
> > Response.Write("")
> > Response.Write("
> > 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 ""
> > dim filename
> > dim filefield
> > response.Write
> > ""
> > response.Write ""
> > Dim strFileName
> > response.Write ""
> > Dim c
> > response.Write "
> > enctype=Multipart/Form-Data runat=Server>"
> > response.Write "File Upload In ASP.Net"
> > response.Write ""
> > response.Write " "
> > response.Write "Choose Your File To Upload : "
> > response.Write "
> > size=60 /> "
> > response.Write " "
> > response.Write "
> > Text=Go /> "
> > response.Write "
> > runat=server>"
> > response.Write "File Name:
> > runat=server/> "
> > response.Write "File Content:
> > runat=server/> "
> > response.Write "File Size:
> > runat=server/>bytes "
> > response.Write ""
> > response.Write "
> > System.IO.Path.GetFileName(strFileName)>"
> > response.Write ""
> > response.write"
> > c)>"
> > response.Write "
> > Sucessfully.>"
> > response.Write ""
> > response.Write ""
> > response.Write ""
> > response.Write ""
> > response.Write ""
> > response.Write ""
> > 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 :-)
>
Re: File Upload question
am 21.04.2008 15:07:07 von Patrice
Humm ? It looks like you are just writing text to the browser including
writing server side code ???!!!. Use "view source" in your browser to see
what you sent...
You may want to trestert fresh from an ASP.NET tutorial...
--
Patrice
"csleimbach" a écrit dans le message
de news: 9C2207DF-3957-4B58-A320-5BDB6D5871C3@microsoft.com...
> 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
>
> "Alexey Smirnov" wrote:
>
>> On Apr 21, 5:52 am, csleimbach
>> wrote:
>> > 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("
>> > 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("
")
>> > 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("
>> > value=""Try
>> > Again"" />")
>> > else
>> > Response.Write("
>> > Value=" &
>> > User & " />")
>> > Response.Write("")
>> > Response.Write("
>> > 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 "
>> > vbDirectory)>"
>> > dim filename
>> > dim filefield
>> > response.Write
>> > ""
>> > response.Write ""
>> > Dim strFileName
>> > response.Write "
>> > FileField.PostedFile.FileName>"
>> > Dim c
>> > response.Write "
>> > enctype=Multipart/Form-Data runat=Server>"
>> > response.Write "File Upload In ASP.Net"
>> > response.Write ""
>> > response.Write " "
>> > response.Write "Choose Your File To Upload : "
>> > response.Write "
>> > runat=server
>> > size=60 /> "
>> > response.Write " "
>> > response.Write "
>> > runat=server
>> > Text=Go /> "
>> > response.Write "
>> > runat=server>"
>> > response.Write "File Name:
>> > runat=server/> "
>> > response.Write "File Content:
>> > id=FileContent
>> > runat=server/> "
>> > response.Write "File Size:
>> > runat=server/>bytes "
>> > response.Write ""
>> > response.Write "
>> > System.IO.Path.GetFileName(strFileName)>"
>> > response.Write ""
>> >
>> > response.write"
>> > c)>"
>> > response.Write "
>> > Sucessfully.>"
>> > response.Write ""
>> > response.Write ""
>> > response.Write ""
>> > response.Write ""
>> > response.Write "
>> > runat=Server/>"
>> > response.Write ""
>> > 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 :-)
>>
Re: File Upload question
am 21.04.2008 19:17:25 von lexa
On Apr 21, 2:54=A0pm, csleimbach
wrote:
> There is no error. =A0When I push the upload button the file does not uplo=
ad. =A0
> I must be missing something.
>
> Thank you for helping me.
>
> Stacy
>
>
>
> "Alexey Smirnov" wrote:
> > On Apr 21, 5:52 am, csleimbach
> > wrote:
> > > I am having trouble with uploading a file to a website. =A0I can not f=
igure
> > > what I am doing wrong. =A0I have a .asp file that you put a username a=
nd
> > > password in that is connected to a database. =A0One of the buttons you=
push is
> > > "Add Press Releasses". =A0It prompts you to choose your file and when =
you
> > > select the upload button it just refreshes. =A0Here is the code:
>
> > > this part works:
> > > Dim Stage
> > > =A0 =A0 Dim Count, i
> > > =A0 =A0 Dim Action
> > > =A0 =A0 Action=3DRequest.Form("Action")
> > > =A0 =A0 Dim AdminCon:set AdminCon=3DServer.CreateObject("ADODB.Connect=
ion")
> > > =A0 =A0 =A0 =A0 AdminCon.Provider =3D "Microsoft.Jet.OLEDB.4.0"
> > > =A0 =A0 =A0 =A0 AdminCon.Open Server.MapPath("databasename.mdb")
> > > =A0 =A0 Dim rs:set rs=3DServer.CreateObject("ADODB.Recordset")
> > > =A0 =A0 Response.Write("
> > > method=3Dpost>") =A0 =A0
> > > =A0 =A0 Dim HostPath
> > > =A0 =A0 HostPath =3D "http://" & Request.ServerVariables("SERVER_NAME"=
) &
> > > Left(Request.ServerVariables("PATH_INFO"), Instr(1,
> > > Request.ServerVariables("PATH_INFO"), "adminpress.asp", 1) - 1)
> > > =A0 =A0 =A0CodeFile=3D"UploadPressRelease.aspx.vb"
> > > =A0 =A0 =A0Inherits=3D"System.Web.UI.Page"
> > > Stage=3DRequest.Form("Pass")
> > > =A0 =A0 if Len(Stage)=3D0 then
> > > =A0 =A0 =A0 =A0 Response.Write("
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
..
..