Hi All,
I have the following code:
Which saves the file as expected however, what it doesn't do is open it again as it dies saying there is "No such file or directory". How can this be when the file is there on the disk?
If this section of the code is commented out the uploaded image appears in the browser as expected, so this only serves to add to the confusion.
I guess I must be missing something obvious but as to what it is I have no idea, can any one help me here?
--
Thanks.
I have the following code:
Code:
sub SaveAttachment
{
my $Success = 0 ;
my $fh = $CGI->upload("MyPrint") || undef ;
my $fn = sprintf("%lX.jpg", time()) ;
my $File = sprintf("%s/%s", UPLOAD_DIR, $fn) ;
if ($fh)
{
$Tmp->param(FileName => $fn) ;
my ($Bytes, $Buffer) = (0, '') ;
sysopen(FILE, $File, O_WRONLY | O_CREAT | O_EXCL ) or die "Error : $!\n" ;
while ($Bytes = read($fh, $Buffer, BUFFER_SIZE))
{
print FILE $Buffer ;
}
close (FILE) ;
$Tmp->param(eMail => $File) ;
open(IMAGE, '<$File') or die "Unable to open $File because: $!\n" ;
my $FileSize = $Img->Read(file => \*IMAGE) ;
warn "$FileSize" if "$FileSize" ;
$Tmp->param(FileSize => $FileSize) ;
close (IMAGE) ;
$Success = 1 ;
}
return $Success ;
}
If this section of the code is commented out the uploaded image appears in the browser as expected, so this only serves to add to the confusion.
I guess I must be missing something obvious but as to what it is I have no idea, can any one help me here?
--
Thanks.