Re: fopen on windows shared, error: failed to open stream

From: Date: Wed, 24 Oct 2007 08:29:08 +0000
Subject: Re: fopen on windows shared, error: failed to open stream
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-28580@lists.php.net to get a copy of this 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

« previous php.windows (#28580) next »