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
unlink not working in IIS
Old 11-04-2004, 10:09 AM unlink not working in IIS
Average Talker

Posts: 16
Trades: 0
I feeling like a fool for asking this question, but I've got an unlink() command in a php script on IIS that gives me a "Permission Denied" error. Obviously, I have checked that the file is read/write, and that the containing folder is also read/write. The original file was created by an upload script. I can create files, and I can even overwrite them - but I can't delete (unlink)! I usually work with Apache/Linux, so maybe I'm missing something really obvious. Oh, and I've tried replacing all forward slashes with backslashes... no effect.

Just for completeness, here's my code:

PHP Code:
// $bulletins_directory is set earlier to the correct container directory

$temp basename($_GET['delete']);
$full_filename realpath($bulletins_directory $temp);
if ( 
file_exists$full_filename ) ) {
  
$delete_worked unlink$full_filename );

Can anyone help?

Last edited by dcs3jah; 11-04-2004 at 12:03 PM..
dcs3jah is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-04-2004, 11:46 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
All i can say is unlink will not remove a directory that has files inside it. If this is the case you will have to poll the directory and remove the files then and only then can you remove the dir.

Ibbo
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 11-04-2004, 12:02 PM Not a directory
Average Talker

Posts: 16
Trades: 0
Nah, I'm trying to delete a single file, not a directory. I'm really starting to develop a distaste for IIS to be honest...
dcs3jah is offline
Reply With Quote
View Public Profile
 
Old 11-04-2004, 12:22 PM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Whay hey thats the spirit.
Drop that beast.

Do your scripts run as a particular user. (for instace under apache all my docs belong to user Apache and group Apache. If I attempt to remove files using my UID it fails with permision denied. If i run a script with apache UID it works just fine.


If so the user (script UID) that created it should remove it.

One simple method is to hard code an unlink like below.

PHP Code:

function deltree($dir$file){
            
        if(
file_exists($dir'/'.$file)){
         if(!
unlink($dir '/'.$file')){
              echo "Not today mate";
          }
        }


Of course thats not efficient but you can play with the idea and see if it gets your files off the sys. Try changing the file param to an array of files to be removed, you can then run it through a loop unlink each file.

Let us know.


Ibbo
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 11-04-2004, 12:38 PM
Average Talker

Posts: 16
Trades: 0
I'm not quite sure what you mean. A php script created the file, so I don't think it's a UID problem. I usually use Linux/Apache, so I'm familiar with that but I've no idea how it work on IIS. Anyway, like I say I don't think it's a UID problem since I'm trying to delete a file that was created by a similar script (so surely the UID's are the same?). I can overwrite, but not delete.

Thanks for your help though.
dcs3jah is offline
Reply With Quote
View Public Profile
 
Old 11-05-2004, 12:18 PM
Average Talker

Posts: 16
Trades: 0
I e-mailed them, and it was a server setting that was wrong. Argh. I thought I was losing it. Thanks for your help anyway Ibbo.
dcs3jah is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to unlink not working in IIS
 

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.27522 seconds with 12 queries