fopen on windows shared, error: failed to open stream

fopen on windows shared, error: failed to open stream

am 23.10.2007 04:22:55 von louie miranda

------=_Part_1138_29229400.1193106175941
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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\afbf7d1fb318054a5ba3e9 d4cca0af.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 ="\r\n";
.....
fwrite($createXML, $_xml, strlen($createXML));
fclose($createXML);

What could be the problem?

--
Louie Miranda (lmiranda@gmail.com)
http://www.axishift.com

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

------=_Part_1138_29229400.1193106175941--

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

am 23.10.2007 06:00:36 von Niel Archer

> 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\afbf7d1fb318054a5ba3e9 d4cca0af.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 ="\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

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

am 24.10.2007 02:02:42 von louie miranda

------=_Part_713_11882213.1193184162609
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi John,

Tried your suggestion. But, it still has the same error.
[function.fopen]: failed to open stream: Invalid argument in



On 10/23/07, John Mertic wrote:
>
> Make sure that the folder you are saving to is available for saving
> for user which the webserver is running as, and double your
> backslashes to make the command look like this:
>
> $createXML =
> fopen("\\\\192.168.10.2\\businesscard\\XML\\".$xml_uniq_sess ion.".xml",
> "w");
>
> John
>
> On 10/22/07, Louie Miranda 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\afbf7d1fb318054a5ba3e9 d4cca0af.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 =" > standalone=\"yes\"?>\r\n";
> > ....
> > fwrite($createXML, $_xml, strlen($createXML));
> > fclose($createXML);
> >
> > What could be the problem?
> >
> > --
> > Louie Miranda (lmiranda@gmail.com)
> > http://www.axishift.com
> >
> > Security Is A Series Of Well-Defined Steps
> > chmod -R 0 / ; and smile :)
> >
>
>
> --
> John Mertic
> jmertic@gmail.com
> http://jmertic.wordpress.com
>
> "Explaining a joke is like dissecting a frog: you understand it
> better, but the frog dies
> in the process." --Mark Twain
>



--
Louie Miranda (lmiranda@gmail.com)
http://www.axishift.com

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

------=_Part_713_11882213.1193184162609--

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

am 24.10.2007 10:29:08 von Niel Archer

> 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\afbf7d1fb318054a5ba3e9 d4cca0af.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 ="\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

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

am 25.10.2007 01:44:50 von louie miranda

------=_Part_1751_31891645.1193269490157
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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 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\afbf7d1fb318054a5ba3e9 d4cca0af.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 =" > 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 (lmiranda@gmail.com)
http://www.axishift.com

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

------=_Part_1751_31891645.1193269490157--

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

am 25.10.2007 02:00:33 von louie miranda

------=_Part_1780_1712286.1193270433094
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

After seeing this:
http://bugs.php.net/bug.php?id=25805

I think i know what the problem is.

Louie

On 10/25/07, Louie Miranda wrote:
>
> 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 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\afbf7d1fb318054a5ba3e9 d4cca0af.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 =" > > 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 (lmiranda@gmail.com)
> http://www.axishift.com
>
> Security Is A Series Of Well-Defined Steps
> chmod -R 0 / ; and smile :)
>



--
Louie Miranda (lmiranda@gmail.com)
http://www.axishift.com

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

------=_Part_1780_1712286.1193270433094--

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

am 25.10.2007 02:10:24 von Mazzu

Have you try to test whether the file is available or not ?

Maybe you should try somehting like this :

$xml_file = '\\\\192.168.10.2\\businesscard\\XML\\'.$xml_uniq_session.'. xml';

if (!file_exists($xml_file)) {
exit('File '.$xml_file.' does not exists or is unavailable');
} elseif (!is_file($xml_file)) {
exit('File '.$xml_file.' is not a regular file');
} elseif (!is_writable($xml_file)) {
exit('File '.$xml_file.' is not writable');
} else {
fopen($xml_file,'w');
}



"Louie Miranda" wrote:
> ------=_Part_1751_31891645.1193269490157
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
>
> 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 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\afbf7d1fb318054a5ba3e9 d4cca0af.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 =" >> 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
>>
>>
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

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

am 25.10.2007 19:03:44 von Niel Archer

Hi Louie

I've tried using both a mapped network drive and the UNC path syntax.
Both work perfectly for me, although I only tried reading, not writing.

Which version of PHP are you using. I'm not sure if versions before 5.0
handle shares at all.

I checked the bug entry you cited, did you read the final entry in it
which describes why it is a permission problem and not a bug? It also
gives advice on how to work around the problem.


--
Niel Archer

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php