473,465 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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 :

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

<?php

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";
}

?>

<form method="post" enctype="multipart/form-data" action="simple.php">
<p>
<input type="file" name="fichier" size="30">
<input type="submit" name="upload" value="Uploader">
</p>
</form>

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

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.

Nov 16 '07 #1
3 4654
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 :

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

<?php

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<hr>";
$target = $content_dir . $name_file;
echo "\$target=$target<hr>";

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";
}

?>

<form method="post" enctype="multipart/form-data" action="simple.php">
<p>
<input type="file" name="fichier" size="30">
<input type="submit" name="upload" value="Uploader">
</p>
</form>

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

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.
Nov 16 '07 #2
the reply works again ! I hope !

Hi ! Thank you for the reply
><?php

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<hr>";
$target = $content_dir . $name_file;
echo "\$target=$target<hr>";

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

Nov 16 '07 #3
Andy2500 wrote:
the reply works again ! I hope !

Hi ! Thank you for the reply
Hi,

What do you mean?
Is your newsreader broken?
>
>><?php

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<hr>";
$target = $content_dir . $name_file;
echo "\$target=$target<hr>";

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.j pg

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_<machinename>

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
Nov 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bert | last post by:
I am new to all this testing server terminolgy. For the last 6 days I have read everything I can find on installing php/mysql, IIS as a testing server. IIS, MySQL, PHP installed and apparently...
2
by: gruddo | last post by:
Hi this is my first post. I have two webservers. I can run php code fine on one but not the other. Both webservers can read files only one can write. I have looked around at other posts and they...
1
by: krishna5 | last post by:
My php program to resize an jpeg image is as follows, ?php // File and new size $filename = '\bala\testPHP\Lavanya\Kids2.jpeg'; //$filename = 'Kids2.jpeg'; $percent = 0.5; // Content type
4
by: Claire DURAND | last post by:
Hi, I try to open a distant (not local) XML file in PHP to read an RSS feed. I can open an HTML page and read it with the file() function. But as soon as I try with a RSS feed instead of...
1
by: daver | last post by:
I just loaded a sql file into mysql but when I go to the address of my website i get the following errors.Any advice Warning: main(templates/cre6.5/main_page.tpl.php): failed to open stream: No...
7
by: diane100 | last post by:
Hi I am new to PHP and Smarty (I know only very basic things) and I need help with a warning message I get when I call a page in a browser. I purchased some software from a company who are no...
12
by: duzhidian | last post by:
failed to open stream: No such file or directory I have the programs like this structure: a.php is locate at . b.php is located at ./lib c.php is located at ./lib/sublib a.php uses a...
6
by: Andy2500 | last post by:
Hi, I'd like to upload an image to a folder, then I have 3 diffrents examples but all of them give an error "failed to open stream: Permission denied", althrough the C:\Inetpub\wwwroot is not...
5
by: Andy2500 | last post by:
the reply doesn't work, I much post a new one , sorry !!!!! Hi ! Thank you for the reply $tmp_file=C:\WINNT\TEMP\php1C.tmp...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.