By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

unlink - permission denied

100+
P: 111
Hi

I am trying to delete a csv file using the unlink() function, but i keep getting a permission denied warning

Warning: unlink(UsedNOS200704191.CSV): Permission denied in E:\webroot\dev\file_test\index.php on line 416


My script basically reads email attachments and downloads the attachment file into the current directory of the running script. The data in the attachements is then read and stored into MySQL. Once i've finished reading this file, i need to delete it.

When i unlink excel files (.xls) everything is OK and this produces no errors/warning, however, when i try to unlink the (.csv) files. i get a permission denied warning.


The same script which creates the file (from email attachment) is doing the deleting (unlink() funtion), once the file has been read. So, therefore in terms of owning a directory or file and having access writes to that directory should not be a problem. as its the same script which created the file in the first place.

The open connection to the file is closed beofre i try to delete it, but this is not the issue.

Why am i able to unlink the excel files and not the csv files, its the same script that creates both file type, reads both file type and eventually (should) delete both file types.

Any help on this mater would be appretiated, as i'm tried everything without much success.

Thanks in advance
Jun 5 '07 #1
Share this Question
Share on Google+
4 Replies


epots9
Expert 100+
P: 1,351
what is your permission set to on the file? i think 750 is the right setting, or u can always try 770
Jun 5 '07 #2

100+
P: 111
I am using PHP in a windows environment, I never knew that the file permission system applied in this environment.

But i have checked the file permissions and it's currently set to: 666 for the CSV file and excel file. So both files have the same file permissions. therefore, if the excel file can be deleted then so should the csv file.

i can't use chmod to change the permissions as its a unix command,

I am using
fopen($filename,"w");
to create the csv file in the first place. Is there a parameter that i have missed out here or another step that follows this.
Jun 6 '07 #3

100+
P: 111
Ok, i've fixed the problem.

basically the connection to the file (after reading from it) wasn't properly closed.

therefore, the file was still open for reading.
Jun 6 '07 #4

Motoma
Expert 2.5K+
P: 3,235
Ok, i've fixed the problem.

basically the connection to the file (after reading from it) wasn't properly closed.

therefore, the file was still open for reading.
I'm glad you found the solution for your problem, and grateful that you posted it back here for the rest of the community to learn from!
Jun 6 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.