Discussion:
fpassthru - not a valid stream resource
(too old to reply)
k***@googlemail.com
2006-10-20 08:48:56 UTC
Permalink
Hi folks,

I've got a small application that displays a word document using :

$fp = readfile($full_fn, "r");
fpassthru ($fp);

(after setting content headers etc and ensuring $full_fn is correct)

It works fine but I get a warning everytime saying:

PHP Warning: fpassthru(): supplied argument is not a valid stream
resource in....

I'm a bit concerned about this warning. $full_fn is the full path to
the file (with the filename). The files are all very small. Any
suggestions on what else I might have done to cause this warning? I
know I can suppress the warning, I'm just confused as to why I'm
getting a warning when the file is quite obviously opening.

Thanks in advance for any suggestions!
p***@gmail.com
2006-10-20 19:14:38 UTC
Permalink
readfile streams the file and returns the number of bytes read. In that
case, no need to use fpassthru:

readfile($full_fn) or trigger_error("Failed to readfile.");
Post by k***@googlemail.com
Hi folks,
$fp = readfile($full_fn, "r");
fpassthru ($fp);
(after setting content headers etc and ensuring $full_fn is correct)
PHP Warning: fpassthru(): supplied argument is not a valid stream
resource in....
I'm a bit concerned about this warning. $full_fn is the full path to
the file (with the filename). The files are all very small. Any
suggestions on what else I might have done to cause this warning? I
know I can suppress the warning, I'm just confused as to why I'm
getting a warning when the file is quite obviously opening.
Thanks in advance for any suggestions!
k***@gmail.com
2006-10-26 11:14:52 UTC
Permalink
Thanks! I misunderstood what readfile did.

Karen
Post by p***@gmail.com
readfile streams the file and returns the number of bytes read. In that
readfile($full_fn) or trigger_error("Failed to readfile.");
Post by k***@googlemail.com
Hi folks,
$fp = readfile($full_fn, "r");
fpassthru ($fp);
(after setting content headers etc and ensuring $full_fn is correct)
PHP Warning: fpassthru(): supplied argument is not a valid stream
resource in....
I'm a bit concerned about this warning. $full_fn is the full path to
the file (with the filename). The files are all very small. Any
suggestions on what else I might have done to cause this warning? I
know I can suppress the warning, I'm just confused as to why I'm
getting a warning when the file is quite obviously opening.
Thanks in advance for any suggestions!
Loading...