Thanks for your post. I have gone over all of my code, and changed it to exactly how you do it.
I have set "PerlSetVar FileUploadTemp 1" and restarted apache.
All pages which upload a file use:

my $upload_file = $Request->{FileUpload}{filename};
# "filename" is the name of the form item.
my $newFileLocation = $upload_file->{TempFile};
my $newFileName = $upload_file->{BrowserFile};

This works fine, although I still have a problem.

I build an array out of the filenames (taken from $newFileName) which is used to add entries for the files into a database.
The problem is, when I use code such as :

# this code is using perls DBI interface...
$add_statement = $dbh->prepare("insert into submission_files values(default,'$last_ID',(?),(?),(?))");
foreach my $file (@$files) {
# execute
$add_statement->execute($file,$fileDescriptions[$i],$signature);
$i++;
}

The database dies with the following error:

Can't bind a reference (Fh=GLOB(0x877e28c)) at /home/application/secure/perl/APP/Submissions/AddSubmission.pm line 168. <--> , /usr/local/lib/perl5/site_perl/5.6.1/Apache/ASP.pm line 1489

This shows that the filename returned by my "$newFileName = $upload_file->{BrowserFile};" is still actually a file glob.

I can solve the problem by quoting $file in the $add_statement->execute() line, but I am sure this shouldnt be neccesary.

It appears that the $upload_file->{BrowserFile}; is malfunctioning, or, (and more probably), that I am totally misunderstanding this.

Richard

Richard,

I'm not quite sure why its doing what its doing. I have only done one real project with Apache::ASP that handles file uploads, but again, how I do it is:

1) Make sure you do a PerlSetVar FileUploadTemp 1 in httpd.conf - this will ensure that Apache::ASP actually downloads the file for you and puts it into a temporary file. Otherwise you just get a filehandle to the file and have to read it and spool it to the file yourself (thats how I understood it anyway).

2) Get the hash with a my $upload_file = $Request->{FileUpload}{upload_form_element};

3) Get the name of the (temporary) file that Apache::ASP downloaded the file into: $filename=$upload_file->{TempFile};

You can then move the file wherever you want. This method works great for me.

Tim
<snip>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to