Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Set Up The Permissions So That My Script Can Simply Fopen A File For Writing.


I am rather new to PHP and a relative newbie to Linux too.
I have a webserver at home (Apache 2.0.48 on SuSe 9.0, PHP4).
I have some scripts, one of them needs to be able to create logfiles
somewhere on my machine. It must also later be able to read from and write
to these files again.

Sofar I get a permission error. I tried chmodding 666 or 777 the directory
in which the files could reside, to no avail.
How do I set up the permissions so that my script can simply fopen a file
for writing. Or if that's not the issue, what am I doing wrong or
overlooking ?

The errors:
Warning: fopen(logfileslog1.txt): failed to open stream: Permission denied
in script1.php on line 142
Warning: fwrite(): supplied argument is not a valid stream resource in
script1.php on line 154
Warning: fclose(): supplied argument is not a valid stream resource in
script1.php on line 161
It's the first I am puzzled about, the 2nd and 3rd are a logical
consequence.

By the way, reading from and writing to a file I have previously created
myself with exactly the names I tried to get created by the script (echoed
the name, ok) is no problem at all.
So I don't think it has much to do with a safemode or open_basedir setting.
I also tried creating the scripts in the same dir the script itself resides.
Did not work either.




View Complete Forum Thread with Replies

Related Forum Messages:
Minimun File Writing Permissions
I believe the chmod command -w- is write only, the minimum file writing permission but what is this in terms of numeric - chmod 755? or 777 .

View Replies !
Blocking With Fopen When File Is Already Open For Writing
I created a very simple application that reads and writes to a file, I was wondering if fopen when opening a file for write access blocks this file, i.e. when another user runs this script the script will halt until the first user closes its file handle.

If not how can I change php behavior to block such access?

View Replies !
Permissions With Fopen
alright I have a problem with fopen.
I have a script in a .htaccess protected directory. Now I am trying to make this script rewrite a file in the server root directory that is a public file. Now for some reason I keep getting permission denied when the script runs.
the password of the directory where the the script resides is the same as owner/pass.
Is there something I need to add to fopen such as user/pass info?
any help appreciated

View Replies !
Fopen & 777 Permissions
Does anyone know why an fopen command would need 777 permissions and not work with 775? How do I fix this?

View Replies !
Fopen Permissions Question
I am doing a file opening script and it says that when i try to write it to a new file or copy it to a new file i am denied. But i can't chmod it before i create it because there is no file. Does anyone know anything that could help me fix this problem?

View Replies !
Permissions Problem With Fopen
I have a file say "a.php" which reads some data from a remote site and saves it to the server in the same folder as itself say as data.txt Code:

View Replies !
Writing Files And Permissions.
If Apache is running as the user "www" and "www" is part of my group "wheel" should'nt i be able to create files with php in a directory that has the permissions of 0775? It seems i always need to make the directory 0777 to write to it, which doesnt seem right.

View Replies !
Fopen Writing At Specific Line
How to make fopen to start writing at specific line in a xml file? I'm trying to put the new input in between <folio> and </folio> which is at the first and last line of that xml file so that it can be read from the flash.


View Replies !
Warning: Fopen() [function.fopen]: Failed To Open Stream: No Such File Or Directory
i am trying to upload csv file from user's computer to main server the code i am using is
PHP Code:

View Replies !
File Permissions
Im in the process of creating a web based frontend for a program called ASK (Active Spam Killer - http://a-s-k.sourceforge.net) and am currently running into a problem. Currently there is a perl based web front end, but it lacks functionality, and is rather bland, although it does work, and it works without changing any file permissions.

The problem im running into is that PHP requires me to make changes to file permissions (ASK files are located OUTSIDE of the web tree) which might end up causing problems as far as security and privacy of email. Has anyone come to any reasonable answer for this type of problem as im sure its a issue for other programs people write.

View Replies !
File Permissions....
I've read the stuff concerning writing to a text file and the related file permission issues on this forum.I have a script that does just that, it takes user-entered data from a Web Form and dumps it to a text file on a server.

This works fine on my private server, but is giving me the error...."Could not open stream.Permission denied on Line..." on the company server...The Company machine uses Windows XP.

I've tried talking to the System Administrator regarding the Permissions,but he says that giving READ/WRITE/EXECUTE Permissions could create Security Issues.

I have been told that previously,a script written in ASP had been used that did exactly the same thing i.e writing to the text file, but there were no File Permissions needed to be set!

View Replies !
4.3 And File Permissions
I know that the PHP "chmod" command sets file permissions, but how do I
retrieve what the permissions are for a particular file using PHP 4.3?

View Replies !
Problem With File Permissions : PHP / FTP
My php-script makes directories and puts files in it.
But via FTP'ing, I can't delete those files anymore.

Also, I need to put a whole bunch of existing files into these,
'made-by-php' directories, and that seems impossible
by means of FTP. I get an 'access denied' error every time.

View Replies !
How Can I Have Permissions To Delete A File?
How can I have permissions to delete a file? example: I have to delete a file, but I don't to public users have permission to delete that file but, with a certain "login" they can.

View Replies !
File Permissions After Copy()
This function basically creates a new dir in a determined location and copies the files from an established dir to the new dir. It copies the files and creates the folder ok, bit it sets the file permissons to 755 for the new folder and file contents. I then get a 550 error if I try to delete or chmod them. Any suggestions? I get permission errors in the script if I use the chgrp and chmod functions also. PHP Code:

View Replies !
How Do You Create A File In PHP And Set Permissions To It?
How do you create a file in PHP and set permissions to it?

View Replies !
File Permissions In Win98
I just wanted to know if there was any way I could change my file permissions so I can use the fopen function in windows 98 using Apache and PHP 4.04???? I know how to do it for Linux but I need it for Win 98.

View Replies !
Change File Permissions
i'm trying to create a file management tool online using php. Everytime i copy or create files or folders though it assigns ownership of the new files or folders to the apache id. i tried using backticks, exec, shell_exec and the php shell commands. php safe mode is off.

i can create the files and folders using shell commands and have tried to change ownership using chown but that doesn't seem to do anything. any insight can help. the goal is to be able to create these files with the same admin user ownership as all the other files on the site.

View Replies !
CHMOD File Permissions
i have a few question about file permissions. which is the best way to set a permission to a mp3 tha ti can play on the website, but if anyone try to get it from the directory they wont be able to?

like if i am playing thissong.mp3 and someone went to the directory to try and get the file music/songs/thissong.mp3 they would get some kind of error. also for folders that don't have a index file. which permission would be the bes tinstead of creating a number of index for each, but not give a use permusic to see the context if the go to mydirectory/functions/ .

View Replies !
File/folder Permissions
I have an upload function that uploads images into a folder. The folder is set to 777. However when I upload an image file to the folder, the file uploaded is set to 600. Therefore it wont appear on web. I'm not sure why this is doing this for??  Im using the php function move_uploaded_file to upload the file.

View Replies !
File Write Permissions
I'm trying to get an open source PHP app working for my company.  It's giving me the following custom error:

FreeMED was unable to create a file to record the healthy status of the system.
The FreeMED directory should be owned by the user that the webserver is running as...
Usually this is 'apache'. You can also fix this by giving universal write access to the home directory of FreeMED.

But that is not advisable from a security standpoint.
I've narrowed it down to the line of PHP that's breaking it here:

$test = CreateObject('FreeMED.FreeMEDSelfTest');
As far as I can tell, I've made the directory it's using as open as possible and it's still giving me that error.  The owner is apache (user and group) and the permissions are (temporarily) set at 0777 (universal read/write).

Is there some PHP or Apache configuration that needs changed to allow PHP this kind of permission?

View Replies !
File Permissions Windows
i am using the LOAD DATA INFILE to load from a txt file. Although it works fine with the MySQL command it does NOT work with Script...does anybody know why?

View Replies !
Rsync And File Permissions
Im sort of new to using rsync to transfer my files. unfortunately it is messing up something with the permissions, and somehow i get a 403 from the server.

View Replies !
File Permissions On Upload
I am uploading picture. This is part of the code

if(!move_uploaded_file($_FILES['fullSizePic'.$propId.$i]['tmp_name'], '../images/properties/'.$imageName) ){
chmod('../images/properties/' . $imageName , 0777);
}

The file uploads and moves into the properties folder. That folder's chmod is 777, but the file's chmod is only 600 making it unreadable by the server. I try to chmod it with php (as you can see above) and it doesn't work.

View Replies !
Not Enough Permissions To Delete A File
I want to delete a file using unlink() function. I'm getting a warning that says that I have no permissions to do that.

I suppose that is because the file I'm trying to delete is under the root directory path. I searched the forum about deleting files but found nothing alike my problem...

View Replies !
Create A Form Simply With PHP
I want to know if it is possible to create a form simply with PHP, or if I have to use HTML for it, and if I can use php, how do I send the form data to a flatfile on the server?

View Replies !
Simply Output; Why Won't It Work?
I have a page that is supposed to just output the entire DB so I can view it. Here is the code:

View Replies !
Upload File Permissions Problem
I've moved an existing site (which I didn't write) from a apache/php/mysql
host under windows to a linux apache/php/mysql host.
I've sorted out most problems except one.

There is an upload function on the site, which uploads files via POST to
temp folder and then moves it into a folder on the host using php function
move_uploaded_file. Under windows this works fine but on the linux host the
uploaded file is created with 600 permissions so it cannot be accessed later
by site visitors. The folder it is uploaded into has 755 permissions. Is
there a way of setting the default file permissions so each uploaded file
can be set to say 644 or do I need to chmod each file after upload?

View Replies !
File Permissions Of PHP Session Files
I noticed that the file permissions (unix) of the PHP session files
have only read and write permissions for the Apache process (600 or rw-
--- ---).

Does anyone have any idea where this permission is set ? I can't find
any
umask or chmod settings for it in the php.ini file. Can't find
anything in
the httpd.conf either. Is it set in the PHP code that implements
session_start()?

View Replies !
Creating A File, Uploading, And Permissions
I'm using php4 and i want to check for a file, if it doesn't exist it
should be created. My problem is i have to create it with specific
permissions specifically 666 so that the script can then write to it. I
don't have ftp access. I'm also looking for any tutorials, recent ones,
using php4 for creating file upload areas, i'm trying to make one of those
as well.

View Replies !
File And Directory Permissions For PHP Application
I make the directory 0777 and then write the file then i make the file i tried a few but they keep from being read im sure the file is ok i think i can handdle file permissions but i think its directory permissions im having a prob with.

Its an image file i write it and then need to use it so make the directory 0777 and then write the file and then what to the file and what to the directory ?

i am using php ftp() but if anyone knows any differences with php chmod() then please tell me apart from that i do a 777 righth now and leave it at that.

what should i being to the directory and file after to make it secure because i dont whant people tampering with them ?

OH AND THIS PROBS ON TH MAC OSX 10.4 TIGER

my chmoding works fine on linux the way it is 0777 and then a 655

+ somtimes i play with the permissions of the directory throgh the os GUI or the shell and i got it to tell me i dont have permissions in the OS but in PHP its ok is this coz PHP got ownership of it when i messed with the addtional BIT.

View Replies !
File Permissions Denied Error
i'm using the following code to create a file. PHP Code:

$fn = "file.php";
    $FileHandle = fopen($fn, 'w+') or die("can't open file");
    $stringData = "Something";
    fwrite($FileHandle, $stringData);
    fclose($FileHandle);

when i check the file properties i can see that the file's permission is set to 644 so when i use the following code to delete it i get a permission denied error. PHP Code:

$myFile = "file.php";
$fh = fopen($myFile, 'w') or die("can't open file");
fclose($fh);

$myFile = "$file.php";
unlink($myFile);

what shall i do to set the permission to 777 when creating the file?

View Replies !
Chmod Mkdir And File Permissions..
I'm trying to create directories and move files with the right permissions. When I make a dir using mkdir I'm setting the permission to 777 to my folder variable $t2 below,

but when I check the chmod it's 755? When I copy files over to this folder the file permission are set to 644 and I can't even get rid of them on the server because it won't allow me to delete them. Is there anyway to set permissions to a file as you're using the copy function? Code:

View Replies !
File Upload :: Warning: Fopen - No Such File Or Directory
I’m getting the following errors when I try to run the script below on a live server. It’s a crude script which uploads text and images directly into MySQL. It works fine on my local machine, I have Apache, PHP4 and MySQL running on windows. The live server is Unix.

When I try to upload images from my loacal pc I get the error below, when I placed an image file within the same directory as the script on the live server and tried to upload it that worked. I wanted the script to allow image uplload from a client pc Can anyone offer a suggestion?

Warning: fopen("C:Apachehtdocs Grey.jpg", "r") - No such file or directory in /usr/local/home/httpd/vhtdocs/sitehostin/moondance/backend/test_imagedb.php on line 57
Code:

View Replies !
Simply Edit And Update Script
Can anyone provide a simple edit/update script. I have only one field that requires updating and the structure is as follows:

user_id = username
User_password = password
url = redirection url

I would like to have th option to edit these three fields and I have tried everything. Can anyone help with a simple script?

View Replies !
Creating A Printable Report Simply, Rtf Or PDF
Over Christmas I produced, using PHP and MySQL, a database and front end to record my familys family tree with a short biography and linked photos and locations if desired. All this works fairly well.

However, as a followup I'd like to create a report this data as a report (or booklet) in printed format. The simplest and probably least satisfactory way is to format it in very simple HTML and import it into the word processor of choice.

Better ways I assume are to export it in PDF or RTF. I am veering toward RTF.

PDF - pros:

Probably the neatest solution from a user point of view.


PDF - cons:

PHP was not compliled on my Slackware 10.0 linux system with the pdf
functions working.

My parents are running XP home, I doubt if phpdev5 (beta) has the same pdf
functions compliled in.

Basically I don't want to go through the rigmarole of recompiling php on two
dissimilar systems.

I could generate XLS-FO directly, then use FOP to generate PDF. I would probably spend a lot of time getting this to work under two separate systems, and have to get java working on XP. Hastle if I am not all that familiar with java.

I could create a DTD, get my script to produce XML and then use a template and something like sablotron to generate XML. That seems like a sledgehammer to crack a nut. Also, I must be getting the wrong end of the stick with XML, as last time I tried it created far far more work than it saved. Saving effort seems to be a large point of XML.


RTF - pros:

Since this is basically one step from hand coding, using my script to directly generate rtf is relatively self contained and therefore not dependent on successfully installing a lot of other stuff.

RTF - cons:

I've still not managed to add images to RTF.

RTF is horrid, wrt to human readability of what my scripts are generating, making debugging rather nasty.

Even if it works now in open office and word I have no way of knowing I have not created broken RTF that future word processors might balk at.

View Replies !
Change File Permissions On Uploaded Files?
I am trying to find a way to change the default file permissions for uploaded files using PHP. When I upload a file using my PHP script the default file permissions are 755. I would like the file to have 744.

View Replies !
What File Permissions To Keep Files Safe From Outside Users
My php source files should have what file permissions to keep them safe from outside users.I have chmod 711 but i want somefiles to be able to be downloaded eg txt,doc files.

View Replies !
Simply Send An Email When A User Registers
i m trying to simply send an email when a user registers, and
i used the mail function and i got the error "Warning: mail(): SMTP
server response: 550 5.7.1 Unable to relay for m@hotmail.com in
C:Extrndxmail.php on line 2" and i have no clue what is wrong?


View Replies !
How To Simply Display On My Page Another Insert From A Different Table.
$judet = $_GET["judet"];

$result = mysql_query ("SELECT oras, id_oras FROM orase WHERE id_oras = '{$judet}' ORDER BY oras");

This is a piece of my code. The variable $judet is working perfect but i have a problem with another variable in the same table with judet witch i can't call.Everything from table orase works i just don't know how to simply display on my page another insert from a different table.

View Replies !
Linux File Permissions On Maildir, Apache User
i have the following problem. I am trying to create maildir
directories on the local filesystem then chmod, chown them to
courier:courier (for courier mail server). the courier mail server
reads and writes on these maildirs on the local filesystem and they
need to have courier:courier ownership. it does not work because the
directories are created with apache:apache ownership and apparently
only root can change ownership. My question is as follows. Is the
only solution to this problem to add the courier user to the apache
group?

View Replies !
Open A File To Store Some Date :: Permissions Dilemma
I want to open a file to store some data. However, when I use fopen('filename', w) I get permission denied. So, I've changed the permissions of the directory to get rid of the permission denied problem. Unfortunately, this seemed to require changing the directory to have permissions 777.

View Replies !
Fopen('myfile.txt', 'r'); No Such File But File Exists
Using Linux/PHP 4.3.2 CLI:

$fileID = fopen('myfile.txt', 'r'); // WORKS JUST FINE

Using Linux/PHP 4.3.8 CLI:

$fileID = fopen('myfile.txt', 'r'); // THROWS WARNING 'no such file or directory "myfile.txt"

Using Windows XP/PHP 5.0.4 CLI:

$fileID = fopen('myfile.txt', 'r'); // THROWS WARNING 'no such file or directory "myfile.txt"

In all three cases this script, let's call it myscript.php, resides in the exact same directory as "myfile.txt". Both scripts have permissions of 0644, same owner, same group (Unix).

For the Windows problem I managed to use a coding solution that will use the absolute path that is generated within $_SERVER['PHP_SELF'] (which apparently only occurs within Windows - have never seen that variable populated when using a UNIX-based OS):

if ($_ENV['windir'] || $_SERVER['windir']) {
    $path = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/') + 1);
   } else {
    $path = ''
   }

This, however, will produce no absolute path information for UNIX-based OS using "myscript.php" to access "myfile.txt". So using older versions of PHP as recent as PHP 4.3.8 within UNIX (Linux), "$fileID = fopen('myfile.txt', 'r');" you have to extract from $argv[0], provided you are using CLI PHP and you just happen to NOT be in the directory where "myscript.php" is housed, otherwise, you obviously get no absolute path info to locate "myfile.txt", and yes, when tested in PHP 4.3.11 and PHP 5.0.4, I constantly got the warning "No such file or directory: "myfile.txt"" even though it's clearly there with myscript.php.

Bottom line: Is there a foolproof way of always obtaining the absolute path of something using CLI PHP; or... what other alternatives have you all come up with using CLI PHP to always reliably locate a file that happens to be in the same directory as your script?

View Replies !
File Re-writing And Moving The File Pointer
i have a text file that looks like this:

<bt>600</bt>
<iregno>123123</iregno>
<users>
<un>2</un>
<u1>
<n>Username</n>
<ema>username@domain.com<ema>
<s>password</s>
<t>user type</t>
<p>profile name</p>
<cat>000000000000000000000000000000000</cat>
</u1>
and so on
</users>

Now i run this big user edit function where im reading in their details and displaying them in forms and so on. They then edit the form fields and i read them back in using $POST. That's the easy part. What i then want to do is re-write a section of my text file.

I have a variable that tells me what user i need to re-write the details for, i also have all the new details that i need to replace the old ones with. So, in logical terms, what i need to do is move my file pointer to that section of the file:

read in $userToEdit variable -> output of variable is <u1> -> move file pointer to next line (<n>username</n>) and let me rewrite the next 6 lines therefore leaving the pointer at </u1> I hope that makes sense. Just basically want to rewrite the text that is there, not append/add.

View Replies !
CMS That Simply Allows Viewers To Change/add Content In Specific Areas.
I"m looking for a simple, light version of CMS that simply allows viewers to change/add content in specific areas. Including haveing a visual bar w/ normal things like adding a paragraph, table, bold, etc. All I need is an ultra simple light version for a client, possibly w/o the use of mySQL.

View Replies !
Fopen Ms Doc File
Is it posible to open a DOC file with fopen? If not is it psoible to open a RTF file in the same format as it is in word pad or MS word.

View Replies !
Fopen And File
I have a couple of scripts that I have written one uses file the other uses fopen, the only difference in the two is the size of the txt file being read. file will not work with larger text files but fopen does, I know that file reads the whole file into one array and fopen actually reads the file one a line at a time. Is there a max size used with file? I have increased my memory in the ini to 32M and larger but file still wont read the larger text files. Whats up with that? Everything is working, I was just curious why it wouldn't work.

View Replies !
File() And Fopen()
$array = file ('http://www.google.de/search?q=expression');
$something = fopen( 'http://www.google.de/search?q=expression', "r");

In this two cases I get always the warning:
Warning: file(http://www.google.de/search?q=expression) - Success in
/home/alpha/kaczor/public_html/a.php on line 10

Why?

Is it connected with GET method? In this case we can't use GET?

View Replies !
Writing To A File
The script below writes to a file and sends back confirmation that all is well. That is working correctly. The problem I am having is when I view the blank data.txt file that I uploaded to the server (and yes, I have put the file permissions to rw-rw-rw) its still blank!!!!!!! despite my little script stating that all is well. The same script works perfectly well on the
totalise server. If the answer is to run the script as cgi I am too sure how to carry out the 7 different suggestions advised at the FAQ. I am OK at saving the script with a .pl or .cgi extsion instead of .php but how do I incorporate the extra line of code(#!/usr/bin/perl?) do I use it everytime I open php in the
script or just once at the start. What exactly is the base path and how do I check to see if it is set correctly. The script in question is: (basically it handles the data(an URL and a description) coming from a html form and writes these to a file(data.txt)

<?php
function WriteToFile ($URL, $Description) {
/* Function WriteToFile takes two arguments--URL and Description--which will
be written to an external file. */
$TheFile = "data.txt";
if(is_writeable($TheFile)){
$Open = fopen ($TheFile, "a");
if ($Open) {
fwrite ($Open, "$URL $Description
");
fclose ($Open);
$Worked = TRUE;
}
}
else
{
$Worked = FALSE;
}

return $Worked;
} // End of WriteToFile Function.
?>
<HTML>
<HEAD>
<TITLE>Using Files</TITLE>
</HEAD>
<BODY>

<?php
/* This page receives and handles the data generated by "form.html". */
$Pattern = "(http://)?([^[:space:]]+)([[:alnum:].,_?/&=-])";

if (eregi($Pattern, $Array["URL"])) {
$Replace = "<a href="http://23" target="_new">23</a>";
$Array["URL"] = eregi_replace($Pattern, $Replace, $Array["URL"]);
$CallFunction = WriteToFile ($Array["URL"], $Array["Description"]);
if ($CallFunction) {
print ("Your submission--$Array[URL]--has been received!<BR>
");
} else {
print ("Your submission was not processed due to a system error!<BR>
");
}
} else {
print ("Please enter a valid Web address!
");
}
?>
</BODY>
</HTML>

View Replies !
PHP Writing To A File Help
I am trying to create a script that will take the MYSQl DB details that have been sent from a form and store it in a file for usage at a later stage.

Am I doing this correctly:

View Replies !
Writing Csv Or Txt File
I am trying to create a method of exporting a csv or plain text file from a mysql database, so that users can save this file to disk for use in Excel or other popular spreadsheet & database applications.

I have a query which selects the records, and I can format it easily enough using HTML table and related tags... Does anyone know a good way to format the results of the query so users can save this file as txt/csv file?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved