PHP Developer's Network : Network Member
Forums

PHP Classes
Icontem

Subject: Failed to open stream


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend!

      MS-Excel Stream Handler   All threads   Failed to open stream   (Un) Subscribe thread alerts  
Subject:Failed to open stream
Summary:failed to open stream
Messages:9
Author:dak
Date:2005-12-28 07:49:13
Update:2008-08-29 16:27:29
 

  1. Failed to open stream   Reply  
Picture of dak
dak
2005-12-28 07:49:13
Hi,

I really hope someone can help me. I'm new to writing PHP scripts. I've been trying to use this class for the last 4 hours but couldn't get it to work. I've downloaded the excel.php, download & export examples into one folder. I've also created a file example.xls in the same folder as well as in another folder called tmp. By the way, I'm using Maguma Studio 1.3.3 and xampp.

I tried running both the download & export examples but got the following errors:

PHP Warning: readfile(xlsfile://tmp/example.xls): failed to open stream: "xlsstream::stream_open" call failed in C:\Documents and Settings\-\My Documents\readexcel2\~scp.php on line 18

Cannot open xlsfile://tmp/example.xlsPHP Warning: fopen(xlsfile://tmp/example.xls): failed to open stream: "xlsstream::stream_open" call failed in C:\Documents and Settings\-\My Documents\readexcel2\~scp.php on line 11

Really hope someone can help me...thanks

  2. Re: Failed to open stream   Reply  
Picture of Phil
Phil
2005-12-30 17:24:10
The reason is... You're trying to write/read a unix compliant directory, not win32.

xlsfile://tmp/example.xls "/tmp/example.xls" isn't a valid windows path, You need to use, for example... C:/example.xls

  3. Re: Failed to open stream   Reply  
Picture of João
João
2006-01-02 12:46:13
My post "is not" for solving your problem!

But if you want to create a complicated excel file see
“Alternative MS-Excel Classes
If you're looking for an Excel class to do more...”
thread in this forum.

I’m using the PEAR package and I’m very happy because handling information is much easier. The installation of PEAR and package is simple too!

  4. Re: Failed to open stream   Reply  
Picture of R S
R S
2006-07-27 17:39:23
This is probably 7 months too late, but for anyone else who is experiencing this problem (as I just was), the problem is in the stream_open() function. The first thing it does is parse $path as a url then it does this:
$this->xlsfilename = '/' . $url['host'] . $url['path'];
presuming that the specified file path is an absolute path, hence the prepending of the root ('/') to the filename. Simply remove the "'/' ." so the line is:
$this->xlsfilename = $url['host'] . $url['path'];
And this will allow users to open files as relative or absolute paths. E.g.,
readfile('xlsfile://./example.xls');
or
readfile('xlsfile://c:/foo/bar.xls');

Obviously, this is all only for Windows systems.

  5. Re: Failed to open stream   Reply  
Picture of onur keskin
onur keskin
2006-09-08 07:03:45
the class doesn't recognize "./". If you give the path as "xlsfile://./file.xls", it creates a file at the root path(for ex. "c:\file.xls").

  6. Re: Failed to open stream   Reply  
Picture of S.M. Mehedi Hasan
S.M. Mehedi Hasan
2007-12-14 11:18:45
Thanks. My problem is solved using ur technique.

  7. Re: Failed to open stream   Reply  
Picture of govanthan
govanthan
2008-05-20 07:06:09
Can u send me ur code as sample

  8. Re: Failed to open stream   Reply  
Picture of Gervasio Marchand
Gervasio Marchand
2008-08-21 19:21:53
Yep, removing '/' worked here too :D thanks!

  9. Re: Failed to open stream   Reply  
Picture of kyungjoon min
kyungjoon min
2008-08-29 16:27:29
Try removing the @ in the following code in the function stream_open.
$this->fp = @fopen($this->xlsfilename, $this->mode);

This will give more exact error code.

If you code like below in window 2003 server,

$fp = fopen('xlsfile://./temp/bar.xls',"wb");

it will open the file bar.xls in C:\temp directory.

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2008 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products