Mark Martin wrote:
Hi,
I've got a web form that allows a user to browse to an excel file on their computer 
and input it and the year as parameters to run a perl script

FORM :

<input type="file" value="excel" name="file" size="15">
<input type="text" name="year" size="15">

SCRIPT:


use strict; # always use warnings;# usually

use CGI;
use Spreadsheet::ParseExcel;
$q=new CGI;

my $oExcel = new Spreadsheet::ParseExcel;
my $user_ssheet=$q->param('file');
my $oBook = $oExcel->Parse($user_ssheet);
my $year=$q->param('year');

BUT I keep getting a "HTTP 500 - Internal server error". However if I hard code in the reference to the excel file, like so :

my $user_ssheet="excel_file.xls";

it works fine !? Is it something to do with paths from the file input type?

I assume your form's enctype is set to allow uploads. You should review the docs for CGI particularly the section on uploading files,


http://search.cpan.org/~lds/CGI.pm-3.04/CGI.pm#CREATING_A_FILE_UPLOAD_FIELD

You should switch to using the 'upload' method and store the contents of the file locally first, or check to see if Spreadsheet::ParseExcel will accept a filehandle instead of a location. Essentially you are correct the value returned in scalar context for param I think is going to be the path of the file on the remote (client) side, which will be invalid on the server side. Your 500 error is probably from lack of header rather than anything to do with the file upload, unless 'Parse' is 'die'ing.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to