Jump to content

Archived

This topic is now archived and is closed to further replies.

otuatail

fopen

Recommended Posts

Hi Strange things are hapening on a lynux server. My original website which had been on a Windows based server worked fine. I had my web hosting company move it to a Lynux server. No it doesn't work. This simple code should work.

<?
$data = "Testing";
$fh = fopen("sample.txt","w");
fwrite($fh,$val . "\r\n");
fclose($fh);

$fh = fopen("sample.txt","r");
$val = fgets($fh);
fclose($fh);
echo($val);
?>

I get an error on fopen

Warning: fopen(sample.txt): failed to open stream: Permission denied in /home/fhlinux190/d/des-otoole.co.uk/user/htdocs/fopen.php on line 3

Any sugestions please.

Share this post


Link to post
Share on other sites
The proble is file permissions. If you can connect to your server with an FTP program then CHMOD your files or folders to 775 or 777 which will allow you to write the files, I believe.

Share this post


Link to post
Share on other sites
Sorry I don't understand this. I have a web hosting company and the only acces outside of html is phpMyadmin

Share this post


Link to post
Share on other sites
I use ftp surfer to transfer all my files to the web server and create database tables by executing the scripts in phpmyadmin. There is a notepad file on the server and in ftpsurfer I can open it up fine.

Share this post


Link to post
Share on other sites
the problem is that fopen tries to open the file, but the server sends the message "you are not autherized to access this file" back to php. The previous post is correct, you need to chmod the file. chmod'ing is basicly telling the computer what people are allowed to access the file.

777 = everyone and their brother in law can read/write/execute the file.

here is a tutorial I found online that explains chmod'ing [url=http://catcode.com/teachmod/]link[/url]. You should have FTP access to your site, (that's how most people upload their files to the server) and most FTP programs will allow you to change permissions of files (chmod). If you dont have a FTP program, [url=http://www.snapfiles.com/reviews/FTP_Wanderer/ftpwanderer.html]here[/url] is a pretty good one that's freeware and allows you to change permissions by right clicking on the files and choosing "properties".

Joe

Share this post


Link to post
Share on other sites
FTP Surfer (which I use) is the same. I can drag and drop a notepad txt file to the server. but access is denied. is it the way that the FTP surfer is doing it or have I got to change some properties in the application/

Desmond.

Share this post


Link to post
Share on other sites
in ftp surfer, login to your ftp site. right click file, choose "change permissions". check mark : read / write under owner and group. try again, if nothing happens, try checking read / write under owner, group, and other. should fix it for you.

Joe

Share this post


Link to post
Share on other sites
When you upload your files you are supposed to upload them to special area, which from looking what was posted earlier, you are supposed to upload your files to the htdocs folder. When you upload a file you are going to be using PHP to open that file to read/write contents to you'll need to set some permission for that file. Which you can do by Right clicking the file and selecting properties from the menu within your FTP program. Somewhere in the properties dialog box you should find a CHMOD area. It'll either be a textbox, with about 9 textboxes. What you'll want to do is the change the number so it reads 0775. Once it reads 0775 or 775 the file will now the correct permissions for PHP to opne/read and write to the file.

Share this post


Link to post
Share on other sites
I can't right click and change permisions BUT I received this email from the web provider.

It appears that the apache has got the permission to access these files, you will need to set these file permissions to writeable and readable to all users.

Using a secure shell program, such as PuTTY, you can access your domain's home directory and carry out advanced maintenance, such as changing file permissions.

Shell access details for your site
Host address:
Username:
Password:

Do I need to buy software called PuTTY. Tried creating a new profile inftpsurfer ssh.des-otoole.co.uk but no use. I am totlay lost on this. Things worked great under wWindows but slow.

Desmond.

[b]PLESE DO NOT POST PRIVATE INFORMATION ON FORUMS, I HAVE REMOVED THE SHELL ACCESS INFO[/b]

Share this post


Link to post
Share on other sites
I have set the file view to details and the file has the following -rw----r--

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.