[PHP] failed to open stream: continued - 2 -

[PHP] failed to open stream: continued - 2 -

am 16.11.2007 08:30:51 von Andy2500

Sorry that I use the new post because when I replied in the old one,
nothing display !


> so php is running fine, indicating that php initiated by a web hit
> does in fact have permissions to read/parse .php files.

> post the errors back here please. ......., we'll need to look at a
> couple of other things more closely.


here is the code of the simplest example with its errors :

==========================================================


if( isset($_POST['upload']) )
{
$content_dir = 'upload/'; // folder that file will move into

$tmp_file = $_FILES['fichier']['tmp_name'];

if( !is_uploaded_file($tmp_file) )
{
exit("file is inaccessible");
}

// copy the file into the folder
$name_file = $_FILES['fichier']['name'];

if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
{
exit("Impossible copy into the folder $content_dir");
}
echo "file is uploaded";
}

?>








-------------------------------------------------------

the errors are :

Warning: move_uploaded_file(upload/Guitarre.jpg) [function.move-uploaded-

file]: failed to open stream: Permission denied in

C:\Inetpub\wwwroot\simple.php on line 20

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move

'C:\WINNT\TEMP\php106.tmp' to 'upload/Guitarre.jpg' in

C:\Inetpub\wwwroot\simple.php on line 20

Impossible copy into the folder upload/


--------------------------------------------------------

PS: WinXP Pro SP2, IIS 5.1 , PHP 5.1.2

It will be highly appreciated that you can test this code and
see if the same errors appear.

Re: [PHP] failed to open stream: continued - 2 -

am 16.11.2007 10:10:38 von Erwin Moller

Andy2500 wrote:
> Sorry that I use the new post because when I replied in the old one,
> nothing display !
>
>
>> so php is running fine, indicating that php initiated by a web hit
>> does in fact have permissions to read/parse .php files.
>
>> post the errors back here please. ......., we'll need to look at a
>> couple of other things more closely.
>
>
> here is the code of the simplest example with its errors :
>
> ==========================================================
>
> >
> if( isset($_POST['upload']) )
> {
> $content_dir = 'upload/'; // folder that file will move into
>
> $tmp_file = $_FILES['fichier']['tmp_name'];
>
> if( !is_uploaded_file($tmp_file) )
> {
> exit("file is inaccessible");
> }
>
> // copy the file into the folder
> $name_file = $_FILES['fichier']['name'];

Hi,

Never trust your own code. ;-)
In case of problems: output what you are doing.

So add here:

echo "\$tmp_file=$tmp_file


";
$target = $content_dir . $name_file;
echo "\$target=$target
";

What output does that give?

Do you recognize the directories?
Is the targetdirectory writable by PHP?

Regards,
Erwin Moller


>
> if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
> {
> exit("Impossible copy into the folder $content_dir");
> }
> echo "file is uploaded";
> }
>
> ?>
>
>

>


>
>
>


>

>
> -------------------------------------------------------
>
> the errors are :
>
> Warning: move_uploaded_file(upload/Guitarre.jpg) [function.move-uploaded-
>
> file]: failed to open stream: Permission denied in
>
> C:\Inetpub\wwwroot\simple.php on line 20
>
> Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
>
> 'C:\WINNT\TEMP\php106.tmp' to 'upload/Guitarre.jpg' in
>
> C:\Inetpub\wwwroot\simple.php on line 20
>
> Impossible copy into the folder upload/
>
>
> --------------------------------------------------------
>
> PS: WinXP Pro SP2, IIS 5.1 , PHP 5.1.2
>
> It will be highly appreciated that you can test this code and
> see if the same errors appear.
>
>
>

Re: [PHP] failed to open stream: continued - 2 -

am 16.11.2007 10:25:17 von Andy2500

the reply works again ! I hope !

Hi ! Thank you for the reply

>> >>
>> if( isset($_POST['upload']) )
>> {
>> $content_dir = 'upload/'; // folder that file will move into
>>
>> $tmp_file = $_FILES['fichier']['tmp_name'];
>>
>>
>> // copy the file into the folder
>> $name_file = $_FILES['fichier']['name'];
>
> Hi,
>
> Never trust your own code. ;-)
> In case of problems: output what you are doing.
>
> So add here:
>
> echo "\$tmp_file=$tmp_file


";
> $target = $content_dir . $name_file;
> echo "\$target=$target
";
>
> What output does that give?

$tmp_file=C:\WINNT\TEMP\php1C.tmp
------------------------------------------------------------ --------------------
$target=upload/Guitarre.jpg

------------------------------------------------------------ --------------------

that means all paths are correct


> Do you recognize the directories?
I think the directories are ok.

> Is the targetdirectory writable by PHP?
Target directory is read & write allowed (tested with cmd and explorer copy
& propriety)
but if it is writable by PHP, I do not know and I think the pb is from here
!

something wrong in my php.ini (version 5.2.1) that it can not writable by
PHP
do you have an idea ?


============================================================ =============
Again the errors :

Warning: move_uploaded_file(upload/Guitarre.jpg)
[function.move-uploaded-file]: failed to open stream: Permission denied in
C:\Inetpub\wwwroot\simple.php on line 27

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
'C:\WINNT\TEMP\php1C.tmp' to 'upload/Guitarre.jpg' in
C:\Inetpub\wwwroot\simple.php on line 27

Impossible copy into the folder upload

Re: [PHP] failed to open stream: continued - 2 -

am 16.11.2007 11:38:39 von Erwin Moller

Andy2500 wrote:
> the reply works again ! I hope !
>
> Hi ! Thank you for the reply

Hi,

What do you mean?
Is your newsreader broken?

>
>>> >>>
>>> if( isset($_POST['upload']) )
>>> {
>>> $content_dir = 'upload/'; // folder that file will move into
>>>
>>> $tmp_file = $_FILES['fichier']['tmp_name'];
>>>
>>>
>>> // copy the file into the folder
>>> $name_file = $_FILES['fichier']['name'];
>> Hi,
>>
>> Never trust your own code. ;-)
>> In case of problems: output what you are doing.
>>
>> So add here:
>>
>> echo "\$tmp_file=$tmp_file


";
>> $target = $content_dir . $name_file;
>> echo "\$target=$target
";
>>
>> What output does that give?
>
> $tmp_file=C:\WINNT\TEMP\php1C.tmp

OK, that looks reasonable.

> ------------------------------------------------------------ --------------------
> $target=upload/Guitarre.jpg

Is THAT allright?
I seriously doubt that.
It is not a full path.

I would expect here something like:
C:\inetpub\wwwroot\somedirectory\upload\Guitarre.jpg

Fix your $content_dir variable, and see if it works.


>
> ------------------------------------------------------------ --------------------
>
> that means all paths are correct

I do not agree with that conclusion.

>
>
>> Do you recognize the directories?
> I think the directories are ok.
>
>> Is the targetdirectory writable by PHP?
> Target directory is read & write allowed (tested with cmd and explorer copy
> & propriety)
> but if it is writable by PHP, I do not know and I think the pb is from here
> !

Well, if you don't know that, find out!
PHP runs on IIS as IUSR_

Find that user, and make sure that user has write right on the
uploaddirectory.


>
> something wrong in my php.ini (version 5.2.1) that it can not writable by
> PHP
> do you have an idea ?

No, nothing wrong with your php.ini, based on what I heard so far.
Maybe there is, but I suggest you first fix the path to a full path and
make sure IUSR can write there before diving into php.ini settings.

Regards,
Erwin Moller

>
>
> ============================================================ =============
> Again the errors :
>
> Warning: move_uploaded_file(upload/Guitarre.jpg)
> [function.move-uploaded-file]: failed to open stream: Permission denied in
> C:\Inetpub\wwwroot\simple.php on line 27
>
> Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
> 'C:\WINNT\TEMP\php1C.tmp' to 'upload/Guitarre.jpg' in
> C:\Inetpub\wwwroot\simple.php on line 27
>
> Impossible copy into the folder upload
>
>
>