Hi,
I'm kind of new to the list, this is my first post
in fact, so please be gentle :)
I've been working on a way to get a file uploaded
from a browser, using perlscript and ASP under IIS 5. Everything I've read
says it's a pretty hairy topic, and I tend to agree. I played with a
couple of components I found around the net to no avail. Recently I
downloaded a component I hadn't tried:
I registered the component on our server, and
tested it with the test upload page which came with the distro, and to my
surprise it worked. The test page was written in VBScript, so I set about
converting it to perlscript. Here's the original VBScript:
if
UCase(Request.ServerVariables("HTTP_METHOD"))="POST" Then
Set fu = Server.CreateObject("AspUtil.FileUpload") fu.directory = Server.MapPath("./attach") rc = fu.Upload If rc = 0 then For n=0 to fu.count-1 set item = fu.item(n) Response.Write "FileName: " & item.filename & "<BR>" Response.Write "Bytes written: " & item.Size & "<BR>" item.Save Next Else Response.Write "File upload failed. RC: " & rc & "<BR>" End If Else ' display some <input
type="file"...> tags and a form with
ENCTYPE="multipart/form-data"
end if
Here's my version, in perlscript:
if($Request->ServerVariables('HTTP_METHOD') eq
"post") {
my $fu = $Server->CreateObject("AspUtil.FileUpload"); $fu->directory = $Server->MapPath("."); my $rc = $fu->Upload; if ($rc == 0) { my $n; for ($n = 0; $n <= ($fu->count-1); $n++) { my $item = $fu->item($n); $Response->write("Filename: " . $item->filename . "<br>\n"); $Response->write("Length: " . $item->size . "<br>\n"); $item->Save; } } else { $Response->write("File upload failed RC: " . $rc . "<br>\n"); } } else { # display some <input type="file"...>
tags and a form with ENCTYPE="multipart/form-data"
}
When I ran the perlscript version here's the error
I got:
Error Type:
my $fu = $Server->CreateObject("AspUtil.FileUpload"); $fu->directory = $Server->MapPath("."); (0x80004005) Can't modify subroutine entry in scalar assignment, at EOF /staff/email/upload.asp, line 16 The line $fu->directory =
$Server->MapPath("."); causes the error. It seems to me that I'm doing
something wrong with the assignment, that you can't use the = operator to assign
something from perlscript to a property of an activex component? Is there
a Win32::OLE method I need to use
maybe?
If anyone can see what I'm doing wrong, please any
help would be incredibly appreciated. Or if anyone has found a workable
way to do browser uploads with perlscript and ASP (not perl and cgi) a link or a
description or especially a code listing would be equally
appreciated.
Thanks in advance,
Josh Reynolds
Multimedia Training Assistant
TRC Multimedia Unit
|
- re: ASP File Upload Josh Reynolds
- re: ASP File Upload Jim Doyle
- Re: ASP File Upload Ron Grabowski
- Re: ASP File Upload Josh Reynolds
- Re: ASP File Upload Josh Reynolds