473,788 Members | 2,706 Online
Bytes | Software Development & Data Engineering Community
+ 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_fi le($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("Impossibl e copy into the folder $content_dir");
}
echo "file is uploaded";
}

?>

<form method="post" enctype="multip art/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_f ile(upload/Guitarre.jpg) [function.move-uploaded-

file]: failed to open stream: Permission denied in

C:\Inetpub\wwwr oot\simple.php on line 20

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

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

C:\Inetpub\wwwr oot\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 4679
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_fi le($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=$tm p_file<hr>";
$target = $content_dir . $name_file;
echo "\$target=$targ et<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("Impossibl e copy into the folder $content_dir");
}
echo "file is uploaded";
}

?>

<form method="post" enctype="multip art/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_f ile(upload/Guitarre.jpg) [function.move-uploaded-

file]: failed to open stream: Permission denied in

C:\Inetpub\wwwr oot\simple.php on line 20

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

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

C:\Inetpub\wwwr oot\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=$tm p_file<hr>";
$target = $content_dir . $name_file;
echo "\$target=$targ et<hr>";

What output does that give?
$tmp_file=C:\WI NNT\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_f ile(upload/Guitarre.jpg)
[function.move-uploaded-file]: failed to open stream: Permission denied in
C:\Inetpub\wwwr oot\simple.php on line 27

Warning: move_uploaded_f ile() [function.move-uploaded-file]: Unable to move
'C:\WINNT\TEMP\ php1C.tmp' to 'upload/Guitarre.jpg' in
C:\Inetpub\wwwr oot\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_di r = '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=$tm p_file<hr>";
$target = $content_dir . $name_file;
echo "\$target=$targ et<hr>";

What output does that give?

$tmp_file=C:\WI NNT\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\wwwr oot\somedirecto ry\upload\Guita rre.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_<machinena me>

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_f ile(upload/Guitarre.jpg)
[function.move-uploaded-file]: failed to open stream: Permission denied in
C:\Inetpub\wwwr oot\simple.php on line 27

Warning: move_uploaded_f ile() [function.move-uploaded-file]: Unable to move
'C:\WINNT\TEMP\ php1C.tmp' to 'upload/Guitarre.jpg' in
C:\Inetpub\wwwr oot\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
4512
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 working but since I have never had any experience with any of them I can't be sure. WinXP Pro IIS PHP 4.3.4.4
2
3591
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 point at not giving permissions to the apache user. I have chmod 777 the directory /var/www/html and the subdirectory test
1
3017
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
3287
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 HTML and I try to read or open with file() or fopen(), it doesn't work, I have the following errors :
1
1555
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 such file or directory in /home/www/sexyliving.cashbizplus.com/index.php on line 309 Warning: main(templates/cre6.5/main_page.tpl.php): failed to open stream: No such file or directory in /home/www/sexyliving.cashbizplus.com/index.php on line 309 ...
7
2693
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 longer replying to my messages for help so I have decided to try and fix the many problems myself. I am receiving the following messages when loading any of my pages and some pages are not even showing at all. Warning:...
12
1746
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 function at b.php while b.php using a function at c.php
6
62768
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 protected. Any suggestions would be helpful, thank you for your time.
5
2350
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 -------------------------------------------------------------------------------- $target=upload/Guitarre.jpg
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10370
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.