tiduck
asked on
File upload with Perl/CGI
I need to upload a file as part of a process of creating a new record in a database. I have a record ID that is stored in the param 'ID'. I extract this and the file name using the following code:
$ID = $cgiobject->param('ID');
$filex = $cgiobject->param('filex') ;
$filex =~ /.*\\(.*)$/;
$filename = $1;
binmode(STDIN); #### ORIGINAL UPLOAD SCRIPT STARTS HERE
@inx = <STDIN>;
foreach (@inx){ # Added so I can see the contents of @inx
print "$_<br>"; # but turns out to be empty
}
splice(@inx,0,4);
splice(@inx,$#inx,1);
$in = join("",@inx);
$in = substr($in,0,length($in) - 2);;
print "$in";
Earlier on in my script I have:
use CGI;
$cgiobject = new CGI;
which allows me to extract the 2 params just fine, but now I'm having trouble obtaining the actual file data. The code from binmode(STDIN) was copied from a file upload script that used to work previously, but seems to return no file data now. Is this because my binmode(STDIN) and $cgiobject calls conflict with each other? Any ideas on how I can get my uploading to work? Thanks in advance!
$ID = $cgiobject->param('ID');
$filex = $cgiobject->param('filex')
$filex =~ /.*\\(.*)$/;
$filename = $1;
binmode(STDIN); #### ORIGINAL UPLOAD SCRIPT STARTS HERE
@inx = <STDIN>;
foreach (@inx){ # Added so I can see the contents of @inx
print "$_<br>"; # but turns out to be empty
}
splice(@inx,0,4);
splice(@inx,$#inx,1);
$in = join("",@inx);
$in = substr($in,0,length($in) - 2);;
print "$in";
Earlier on in my script I have:
use CGI;
$cgiobject = new CGI;
which allows me to extract the 2 params just fine, but now I'm having trouble obtaining the actual file data. The code from binmode(STDIN) was copied from a file upload script that used to work previously, but seems to return no file data now. Is this because my binmode(STDIN) and $cgiobject calls conflict with each other? Any ideas on how I can get my uploading to work? Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.