Can anyone tell me why I'm getting what appears to be a false EOF during a file read using the [read{}] function?
The read file opens OK
The write file opens OK
The original file size is 1570 bytes.
The copied file size is 115 bytes. (Copy appears to terminate on byte value = 26)
The script is:
$path_to_file1 = "transfers\\hello_world.pdf";
$path_to_newfile = "database\\hello_world.out";
# start displaying the HTML page
print "Content-type: text/html\n\n";
print "<html><head></head>\r\n";
print "<body>\r\n";
open (READFILE, "$path_to_file1") || &errorfunc("Couldn't open the file [$path_to_file1] to read.");
print "The file [$path_to_file1] was opened for reading<br>";
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $path_to_file1;
print "The size of file [$path_to_file1] is $size<br>";
open (WRITEFILE, ">$path_to_newfile") || &errorfunc("Couldn't open the file [$path_to_newfile] to write.");
print "The file [$path_to_newfile] was opened for writing<br>";
while (read READFILE, $buf, 16384) {
print WRITEFILE $buf;
}
close (READFILE);
close (WRITEFILE);
print "<br><br>Finished copying from [$path_to_file1] to [$path_to_newfile]<br>";
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $path_to_newfile;
print "Size of [$path_to_newfile] is $size";
print "<br><br></body></html>";
exit;
}
sub errorfunc {
@args = @_;
print "$args[0]<br>";
print "<br><br></body></html>";
exit;
}
The read file opens OK
The write file opens OK
The original file size is 1570 bytes.
The copied file size is 115 bytes. (Copy appears to terminate on byte value = 26)
The script is:
$path_to_file1 = "transfers\\hello_world.pdf";
$path_to_newfile = "database\\hello_world.out";
# start displaying the HTML page
print "Content-type: text/html\n\n";
print "<html><head></head>\r\n";
print "<body>\r\n";
open (READFILE, "$path_to_file1") || &errorfunc("Couldn't open the file [$path_to_file1] to read.");
print "The file [$path_to_file1] was opened for reading<br>";
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $path_to_file1;
print "The size of file [$path_to_file1] is $size<br>";
open (WRITEFILE, ">$path_to_newfile") || &errorfunc("Couldn't open the file [$path_to_newfile] to write.");
print "The file [$path_to_newfile] was opened for writing<br>";
while (read READFILE, $buf, 16384) {
print WRITEFILE $buf;
}
close (READFILE);
close (WRITEFILE);
print "<br><br>Finished copying from [$path_to_file1] to [$path_to_newfile]<br>";
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $path_to_newfile;
print "Size of [$path_to_newfile] is $size";
print "<br><br></body></html>";
exit;
}
sub errorfunc {
@args = @_;
print "$args[0]<br>";
print "<br><br></body></html>";
exit;
}