asp problem

PHaRGoTH

Newcomer
Joined
Apr 29, 2004
Messages
7
HI!
im currently trying to do a form that upload to a database some information and a file.

the part referent of putting the information in the DB was easy but now when i try to add the code referent to the upload of the file it says:

"Cannot use the generic Request collection after calling BinaryRead."
this is the code that i have:

if (Request.ServerVariables("REQUEST_METHOD") = "POST") then

if (request("Browse")="") then
Set upload = Server.CreateObject( "w3.upload" )
Set fileName= upload.Form( "browse" )

if fileName.IsFile then
fileName.SaveToFile( Request.ServerVariables( "APPL_PHYSICAL_PATH" ) & "\\" & fileName )

end if
end if

criarNoticia Request("data"), Request("browse"), Request("titulo"), Request("destaque"), Request("corpo")
Response.Redirect "indice.asp"
end if
 
PHaRGoTH said:
HI!
im currently trying to do a form that upload to a database some information and a file.

the part referent of putting the information in the DB was easy but now when i try to add the code referent to the upload of the file it says:

"Cannot use the generic Request collection after calling BinaryRead."
this is the code that i have:

if (Request.ServerVariables("REQUEST_METHOD") = "POST") then

if (request("Browse")="") then
Set upload = Server.CreateObject( "w3.upload" )
Set fileName= upload.Form( "browse" )

if fileName.IsFile then
fileName.SaveToFile( Request.ServerVariables( "APPL_PHYSICAL_PATH" ) & "\\" & fileName )

end if
end if

criarNoticia Request("data"), Request("browse"), Request("titulo"), Request("destaque"), Request("corpo")
Response.Redirect "indice.asp"
end if
Most people have there HtmlInputFile running at the server. Thus they don't need all of that extra stuff you have. They do their database portion usually after they know the file was successfully uploaded:

btnUpload_Click()
{
//iFile = HtmlInputFile
try
{
iFile.SaveAs(Request.PhysicalApplicationPath + "\\" + newName);
}
catch
{
//write error or whatever
return;
}
//Do db stuff...if there was an error uploading we wouldn't get to this point
}
Your doing your ASP.NET as if it's ASP. Remember that FileName is the client full path to the file, so FileName = "C:\Folder\Folder\FileName.txt" and if you try to save that to the server you will get an error.
 
Back
Top