php-windows Digest 24 Oct 2007 23:44:57 -0000 Issue 3359

Topics (messages 28580 through 28581):

Re: fopen on windows shared, error: failed to open stream
        28580 by: Niel Archer
        28581 by: Louie Miranda

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
> I have this error when ever i try to save an xml file over a windows shared
> folder
> 
> *Warning*:
> fopen(\\192.168.10.2\businesscard\XML\afbf7d1fb318054a5ba3e9d4cca0af.xml) [
> function.fopen]: failed to open stream: Invalid argument in *
> E:\\businesscard\create.php* on line *663*
> 
> my code:
> $createXML =
> fopen("\\\\192.168.10.2\businesscard\XML\".$xml_uniq_session.".xml", "w");
> $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n";
> ....
> fwrite($createXML, $_xml, strlen($createXML));
> fclose($createXML);
> 
> What could be the problem?

Your path is probably invalid as backslashes are escapes inside double
quotes.  So the single backslashes act as escapes on the following
character, which results in no separation between directories.
Workarounds include:
Use forward slashes for paths inside double quotes,
   fopen("////192.168.10.2/businesscard/XML/" . $xml_uniq_session . ".xml", 
"w");
escape the backslashes themselves
   fopen("\\\\\\\\192.168.10.2\\businesscard\\XML\\".$xml_uniq_session.".xml",
"w");
or single quotes
   fopen('\\\\192.168.10.2\businesscard\XML\' . $xml_uniq_session . '.xml', 
"w");

--
Niel Archer

--- End Message ---
--- Begin Message ---
Tried both..

Use forward slashes for paths inside double quotes,
  fopen("////192.168.10.2/businesscard/XML/" . $xml_uniq_session . ".xml",
"w");
escape the backslashes themselves

fopen("\\\\\\\\192.168.10.2\\businesscard\\XML\\".$xml_uniq_session.".xml",
"w");
or single quotes
  fopen('\\\\192.168.10.2\businesscard\XML\' . $xml_uniq_session . '.xml',
"w");

But, PHP is still giving me
[function.fopen]: failed to open stream: Invalid argument in

This might be a bug? It looks simple, but what is the exact point when it
says "failed to open stream?"

Louie

On 10/24/07, Niel Archer <[EMAIL PROTECTED]> wrote:
>
> > I have this error when ever i try to save an xml file over a windows
> shared
> > folder
> >
> > *Warning*:
> >
> fopen(\\192.168.10.2\businesscard\XML\afbf7d1fb318054a5ba3e9d4cca0af.xml) [
> > function.fopen]: failed to open stream: Invalid argument in *
> > E:\\businesscard\create.php* on line *663*
> >
> > my code:
> > $createXML =
> > fopen("\\\\192.168.10.2\businesscard\XML\".$xml_uniq_session.".xml",
> "w");
> > $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\"
> standalone=\"yes\"?>\r\n";
> > ....
> > fwrite($createXML, $_xml, strlen($createXML));
> > fclose($createXML);
> >
> > What could be the problem?
>
> Your path is probably invalid as backslashes are escapes inside double
> quotes.  So the single backslashes act as escapes on the following
> character, which results in no separation between directories.
> Workarounds include:
> Use forward slashes for paths inside double quotes,
>    fopen("////192.168.10.2/businesscard/XML/" . $xml_uniq_session .
> ".xml", "w");
> escape the backslashes themselves
>
> fopen("\\\\\\\\192.168.10.2\\businesscard\\XML\\".$xml_uniq_session.".xml",
> "w");
> or single quotes
>    fopen('\\\\192.168.10.2\businesscard\XML\' . $xml_uniq_session .
> '.xml', "w");
>
> --
> Niel Archer
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com

Security Is A Series Of Well-Defined Steps
chmod -R 0 / ; and smile :)

--- End Message ---

Reply via email to