otuatail Posted July 27, 2006 Share Posted July 27, 2006 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 fopenWarning: fopen(sample.txt): failed to open stream: Permission denied in /home/fhlinux190/d/des-otoole.co.uk/user/htdocs/fopen.php on line 3Any sugestions please. Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/ Share on other sites More sharing options...
ShogunWarrior Posted July 27, 2006 Share Posted July 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64672 Share on other sites More sharing options...
otuatail Posted July 27, 2006 Author Share Posted July 27, 2006 Sorry I don't understand this. I have a web hosting company and the only acces outside of html is phpMyadmin Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64674 Share on other sites More sharing options...
kenrbnsn Posted July 27, 2006 Share Posted July 27, 2006 How do you upload your scripts?Ken Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64693 Share on other sites More sharing options...
otuatail Posted July 27, 2006 Author Share Posted July 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64700 Share on other sites More sharing options...
Phrozin Posted July 27, 2006 Share Posted July 27, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64702 Share on other sites More sharing options...
otuatail Posted July 27, 2006 Author Share Posted July 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64706 Share on other sites More sharing options...
Phrozin Posted July 27, 2006 Share Posted July 27, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64707 Share on other sites More sharing options...
wildteen88 Posted July 27, 2006 Share Posted July 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-64708 Share on other sites More sharing options...
otuatail Posted July 28, 2006 Author Share Posted July 28, 2006 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 siteHost 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] Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-65073 Share on other sites More sharing options...
otuatail Posted July 28, 2006 Author Share Posted July 28, 2006 I have set the file view to details and the file has the following -rw----r-- Quote Link to comment https://forums.phpfreaks.com/topic/15808-fopen/#findComment-65076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.