Current location: Hot Scripts Forums » Programming Languages » PHP » creating files in linux with php


creating files in linux with php

Reply
  #1 (permalink)  
Old 03-18-06, 08:10 PM
klaniak klaniak is offline
Wannabe Coder
 
Join Date: Apr 2005
Location: Underground
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
creating files in linux with php

Hello !!

I created files in linux that contain html code.
The files were created using
fopen($afilename, 'a+') function. The problem is that when I try to view them it
says file not found
(the filenames are chmoded to 755 when they're created)

What can cause this problem, I tested this script on windows xp and it works fine but in linux beats me can't figure it out.

Anybody had this problem and fix it or where can I find more info about this problem ?

Thank you!!!
Reply With Quote
  #2 (permalink)  
Old 03-20-06, 01:39 AM
Patiek Patiek is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
Based on what you said, I am guessing that you are successfully creating the files? In other words, have you double checked via FTP that the files are being created?

Are you accessing the files with the same case? Remember, Linux is CaSe SeNsItIvE, so Something.txt is different from something.txt .

Also, you should not chmod the files to 755 unless they are CGI files that you are executing as programs (which is 99.9% not the case). If you want to simply have read access to the files then 644 will work. If you want to have read / write access then 666 will work.
Reply With Quote
  #3 (permalink)  
Old 03-20-06, 03:17 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
make sure the directory you add the file to is CHMOD 777.

PHP Code:

<?php

// this is the directory (files must be CHMOD to 777)
$dir '/home/user/public_html/files/';

$text 'some text here';
$filename 'blah.txt';

$file fopen($dir $filename"w");
fwrite($file$text);
fclose($file);
?>
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to recode my php script into c to run on linux... DaJackal C/C++ 1 02-03-06 08:22 PM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
Creating Dynamic Images With PHP cdphreaker PHP 0 02-20-05 03:26 PM
PHP Runner , Preview PHP files ! moslehi@gmail.com General Advertisements 3 12-08-04 03:01 PM
Creating a Zip file with PHP dannyallen PHP 3 07-01-04 08:47 AM


All times are GMT -5. The time now is 06:38 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.