Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
fopen - deleting created files
Old 07-05-2006, 10:49 AM fopen - deleting created files
Experienced Talker

Posts: 36
Name: Hayden Shaw
Trades: 0
I am new to using PHP and i am trying to create a script that will create a folder and place a html document in the folder. So far i have done this with the following code

mkdir ("{$rootpath}/{$username}", 0755);
$filename="{$rootpath}/{$username}/index.html";
$file=fopen($filename,"w", 0777);
fwrite($file, "Hello\n");
fclose($file);

But the problem i am having is that once the file index.html is created i am unable to delete it from the sever. I have tried deleting it using WS FTP but it just wont delete. Can anyone tell me how to fix this?
__________________

Please login or register to view this content. Registration is FREE
ezhs8554 is offline
Reply With Quote
View Public Profile Visit ezhs8554's homepage!
 
 
Register now for full access!
Old 07-05-2006, 12:16 PM Re: fopen - deleting created files
Webmaster Talker

Posts: 626
Trades: 0
Try this and see if it works:

Code:
 
mkdir ("{$rootpath}/{$username}", 0755);
$filename="{$rootpath}/{$username}/index.html";
$file=fopen($filename,"w", 0777);
fwrite($file, "Hello\n");
fclose($file);

unlink($file);
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 07-05-2006, 09:29 PM Re: fopen - deleting created files
Experienced Talker

Posts: 36
Name: Hayden Shaw
Trades: 0
I am not wanting to delete the file using PHP i am just wanting to delete the file at a later date using FTP. But every file i have created using the script at the top will not delete using FTP it just comes up with an error saying "550 Could not delete index.html: Permission denied". This only happens with files created with the php code.
__________________

Please login or register to view this content. Registration is FREE
ezhs8554 is offline
Reply With Quote
View Public Profile Visit ezhs8554's homepage!
 
Old 07-08-2006, 04:01 AM Re: fopen - deleting created files
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Try chmod($filename, 0777) after creating the file. By default permissions are 644 and the owner is the user which runs the server, usually it is apache, www or nobody. No wonder that you cannot delete the file via FTP.

Also it seems like you should set 777 to the folder also.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 07-08-2006, 04:13 AM Re: fopen - deleting created files
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
try unlink(filename); , If php created it php should be able to delete it.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Reply     « Reply to fopen - deleting created files
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.54581 seconds with 12 queries