469,266 Members | 2,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,266 developers. It's quick & easy.

unlink - permission denied

111 100+
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
4 12451
epots9
1,351 Expert 1GB
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
nitinpatel1117
111 100+
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
nitinpatel1117
111 100+
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
3,237 Expert 2GB
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.

Similar topics

1 post views Thread by Chamomile | last post: by
10 posts views Thread by lorenzogordon | last post: by
6 posts views Thread by Benjamin | last post: by
reply views Thread by private.anders | last post: by
reply views Thread by private.anders | last post: by
11 posts views Thread by byteoart | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.