473,666 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Try to write files using php5 on Linux

Help!

I am using SuSE 9.3, php5 and Apache2 on Linux. I try to write files to
the hard drive using the following command:

$filename = "test.txt";
if (!file_exists($ filename))
touch($filename );
if (is_writable($f ilename))
$myfile = fopen( $filename,'w+') ;
else
{
echo "Cannot write to file ($filename)";
exit(1);
}

The script neither creates a file nor open it for writing. When using
the same script on Windows everything works fine so I think it is a
permission problem.

Thanks in advance,

Matthias
Jul 22 '05 #1
22 2464
Matthias Braun wrote:
check the owner:group permission on the folder/file
if (!($fp = fopen(TEMPLATE_ PATH.$path.'/'.$file, 'w')))
{
echo "ERROR open file";
} else {
fwrite($fp, $content);
fclose($fp);
}

Bye

R
Jul 22 '05 #2


Matthias Braun wrote:
Help!

I am using SuSE 9.3, php5 and Apache2 on Linux. I try to write files to
the hard drive using the following command:

$filename = "test.txt";
if (!file_exists($ filename))
touch($filename );
if (is_writable($f ilename))
$myfile = fopen( $filename,'w+') ;
else
{
echo "Cannot write to file ($filename)";
exit(1);
}

The script neither creates a file nor open it for writing. When using
the same script on Windows everything works fine so I think it is a
permission problem.


Remember on Linux, the Apache web server runs as a process with very
little priveleges. If you need it to write to a file, the directory
which the file will be in needs to be writeable by everyone.

Ken

Jul 22 '05 #3
Matthias Braun wrote:
Help!

I am using SuSE 9.3, php5 and Apache2 on Linux. I try to write files to
the hard drive using the following command:

$filename = "test.txt";
if (!file_exists($ filename))
touch($filename );
if (is_writable($f ilename))
$myfile = fopen( $filename,'w+') ;
else
{
echo "Cannot write to file ($filename)";
exit(1);
}

The script neither creates a file nor open it for writing. When using
the same script on Windows everything works fine so I think it is a
permission problem.

Thanks in advance,

Matthias


What are your permissions for the directory? Does the Apache user have write
permission for it?
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 22 '05 #4
SOR
<comp.lang.ph p , Matthias Braun , ma*******@web.d e>
<42************ ***********@new sread4.arcor-online.net>
<Fri, 22 Jul 2005 17:30:41 +0200>
I am using SuSE 9.3, php5 and Apache2 on Linux. I try to write files to
the hard drive using the following command:

$filename = "test.txt";
if (!file_exists($ filename))
touch($filename );
if (is_writable($f ilename))
$myfile = fopen( $filename,'w+') ;
else
{
echo "Cannot write to file ($filename)";
exit(1);
}

The script neither creates a file nor open it for writing. When using
the same script on Windows everything works fine so I think it is a
permission problem.


touch($filename ); chmod($filename , 0766);

TMK once you create a file you need to chmod it before you can write to
it and what the folder (if any) is chmodded to is also important for non
windows hosting .
Jul 22 '05 #5
SOR
<comp.lang.ph p , SOR , we*******@spare sorrepair.co.uk .INVALID>
<MP************ ************@no-cancel.newsread er.com>
<Fri, 22 Jul 2005 18:17:10 +0100>
chmod($filename , 0766);


With regard to the webpage('filena me.php') thingy .

Why isnt chmod(,) called something like change(,) if the name assigned
to the function isnt important .

Or do some things only count or have any value when it suits you ? .
Jul 22 '05 #6


SOR wrote (in part):
Why isnt chmod(,) called something like change(,) if the name assigned
to the function isnt important .

Or do some things only count or have any value when it suits you ? .


chmod is a UNIX/Linux command. AFAIK, PHP was first developed on a
UNIX/Linux platform, so you would expect some of the familiar commands
to be named the same.

Ken

Jul 22 '05 #7
SOR
<comp.lang.ph p , Ken Robinson , ke******@rbnsn. com>
<11************ **********@g43g 2000cwa.googleg roups.com>
<22 Jul 2005 10:59:25 -0700>
Why isnt chmod(,) called something like change(,) if the name assigned
to the function isnt important .

Or do some things only count or have any value when it suits you ? .


chmod is a UNIX/Linux command. AFAIK, PHP was first developed on a
UNIX/Linux platform, so you would expect some of the familiar commands
to be named the same.


What a croc of shit .

PHP has been getting developed for how many years ? .

Is putting or adding in something like webpage() beneath them or summit
and isnt part of php supposed to be about the ease of use .

What do you think the chances are that a newbie will type in headers if
they want to find out how to goto a new webpage .
Jul 22 '05 #8
I noticed that Message-ID:
<MP************ ************@no-cancel.newsread er.com> from SOR contained
the following:

What do you think the chances are that a newbie will type in headers if
they want to find out how to goto a new webpage .


It's a difficult one. People who are used to pointy clicky environments
(I'm not just talking about you - I see this with many of my students)
have got used to a lot of hand holding. PHP on the other hand is a bit
geeky and developed by and for people who want full control of how
things work. I'm sure you'd be even more frustrated by ASP.NET

But they can take things too far. For instance, look up 'delete' in the
manual.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 22 '05 #9
SOR wrote:
<comp.lang.ph p , Ken Robinson , ke******@rbnsn. com>
<11************ **********@g43g 2000cwa.googleg roups.com>
<22 Jul 2005 10:59:25 -0700>
Why isnt chmod(,) called something like change(,) if the name assigned
to the function isnt important .

Or do some things only count or have any value when it suits you ? .


chmod is a UNIX/Linux command. AFAIK, PHP was first developed on a
UNIX/Linux platform, so you would expect some of the familiar commands
to be named the same.

What a croc of shit .

PHP has been getting developed for how many years ? .

Is putting or adding in something like webpage() beneath them or summit
and isnt part of php supposed to be about the ease of use .

What do you think the chances are that a newbie will type in headers if
they want to find out how to goto a new webpage .


I started learning PHP a couple of years ago. It was somewhere around my 18th
or 20th language - I've been programming for close to 40 years, and have
forgotten more languages than I remember.

Even without a Unix background I found PHP quite easy to learn. Like any
language you need to learn the operators, built-in function names and the like.
But it's close enough to C, C++ and Java that I had no real trouble at all.

And yes, I found header() quite easily in the documentation. But I guess that's
because I was already familiar with HTML headers.

As for why chmod() isn't called change() - if you just used change(), what would
you be changing?

Spend a few hours, learn the functions - just like any other language.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 23 '05 #10

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

Similar topics

5
1855
by: LRW | last post by:
I've been using PHP for a few years now, have used ASP in the past, and PHP (IMO) is far superior! However, last year I had the opportunity to do some work in ASP.Net...and wow! Really liking what .Net can do. Anyway, I've seen a lot of teasing statements about new OO features in PHP5, but I can't really find any comprehensive site detailing these new OO features, what they are, what they do, how to use them. Any suggestions? I did a...
2
14159
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
0
1452
by: _andrea.l | last post by:
I'd like to use php5 but at my work we use PHP4. How can use both togheter? I work whith Linux Fedora 4 then I have PHP5 installed so how can install PHP4 and use PHP5 for my experiment and PHP4 for works? Thank you in advance, Andrea.
0
2557
by: Rithish | last post by:
OS : RHEL3 PHP version : 5.0.2 JDK version : 1.5.0.06 I have been trying to compile PHP with JAVA support for the past week, and all I have left to do is take a noose and hang myself. Of all the articles, tutorials, posts that I have seen and browsed ( none of them on PHP5+ though ), all of them speak of a libphp_java.so/java.so file being created. However, no such file is being created. I have tried almost all the tips and tricks that...
1
2359
by: R | last post by:
Hi All, I'm using UTF-8 encoding for my PHP scripts, output is also UTF-8. all files have UTF-8 BOM: 0xEF 0xBB 0xBF at the beginning I have PHP Version 5.1.2 on WinNT and PHP 5.1.1 on Gentoo given code:
4
14206
by: Chuck Anderson | last post by:
My Web Host (Linux - Apache) recently upgraded to Php5. One thing lost in the upgrade was a global configuration that allowed me to place php.ini files in any directory and they would be read and used (I don't know if that was in addition to a global php.ini file or not). Prior to that (a couple of years ago) php directives were placed in the htaccess file in the site's root directory, but after an even earlier upgrade the htaccess...
1
5776
by: Kesavan | last post by:
I install apache2 in /usr/local/apache2 and install php5 by ./configure --with-apxs2=/usr/local/apache2/bin/ apxs PHP is successfully installed in my system. But now my .php files inside /usr/local/apache2/htdocs doesn't get phrased. When I run suse-10-2:/home/kesavan # php info.php
3
5867
by: cheesecaker | last post by:
For some reason, when PHP starts, it doesn't want to load some extensions that I KNOW are there. Here's the startup log: Parent: Received restart signal -- Restarting the server. Child 5176: Exit event signaled. Child process is ending. PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Apache2\php5\ext\php_exif.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to...
20
5101
by: cscorley | last post by:
For some reason, I cannot use fopen() on the file in write mode. The file "time" is in the same directory as the .php file, with permissions set to 0766. PHP Version 5.2.5 Apache/2.2.8 code snip in question: $file = "time";
0
8448
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
8356
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
8640
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...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
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
4198
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...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
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
2
1776
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.