Jump to content


Photo

fopen


  • Please log in to reply
10 replies to this topic

#1 otuatail

otuatail
  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 27 July 2006 - 03:22 PM

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.


#2 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 27 July 2006 - 03:30 PM

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.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#3 otuatail

otuatail
  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 27 July 2006 - 03:34 PM

Sorry I don't understand this. I have a web hosting company and the only acces outside of html is phpMyadmin


#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 27 July 2006 - 03:49 PM

How do you upload your scripts?

Ken

#5 otuatail

otuatail
  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 27 July 2006 - 03:53 PM

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.



#6 Phrozin

Phrozin
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 27 July 2006 - 04:00 PM

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 link. 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, here is a pretty good one that's freeware and allows you to change permissions by right clicking on the files and choosing "properties".

Joe

#7 otuatail

otuatail
  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 27 July 2006 - 04:06 PM

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.


#8 Phrozin

Phrozin
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 27 July 2006 - 04:12 PM

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

#9 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 July 2006 - 04:13 PM

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.

#10 otuatail

otuatail
  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 28 July 2006 - 09:42 AM

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.

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

#11 otuatail

otuatail
  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 28 July 2006 - 09:57 AM

I have set the file view to details and the file has the following -rw----r--




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users