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
4 12803 epots9 1,351
Recognized Expert Top Contributor
what is your permission set to on the file? i think 750 is the right setting, or u can always try 770
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.
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.
Motoma 3,237
Recognized Expert Specialist
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!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I wrote some code that let me upload a file to my server. Then I wrote
some code to let me delete the file. But when I try to delete, I get
this error:
Warning: Unlink failed (Permission denied)...
|
by: Bob Bedford |
last post by:
I've tried everything seen on Internet, but nothing works:
I'm trying to move a file from a dir to a subdir (WinXP Pro, Apache, PHP
4.3.3)
Here is the code:
chmod($XMLPath, 0777);...
|
by: Phil Powell |
last post by:
print_r(is_file("$logPath/$logFileName")); // RETURNS 1
unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED
This code should tell me that the file located at...
|
by: Chamomile |
last post by:
I am having trouble getting unlink() to work on my local machine
(win 2000, Apache, php 4.2.2)
when I invoke unlink() in order to change a file name during
a 'picture edit' change from a form...
|
by: lorenzogordon |
last post by:
Hi there,
I'd greatly appreciate any insights into the following problem:
I've got PHP running fine on IIS (OS: Server 2003, SP1; IIS: 6.0; PHP:
4.3.11).
In PHP, the user uploads a file,...
| |
by: Benjamin |
last post by:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
to unlink I get this: "Warning: unlink(file.txt) :
Permission denied..." What and how do I change this so it works?
Thanks
|
by: private.anders |
last post by:
Hi David!
Really need assistance since I have been struggling with a problem
long time now.
I am running a web application on a Win 2003 Std (Active Directory).
Everything works fine. I have...
|
by: private.anders |
last post by:
Really need your assistance since I have been struggling with a
problem long time now.
I am running a web application on a Win 2003 Std (Active Directory).
Everything works fine. I have...
|
by: byteoart |
last post by:
I'm a newbie to php. I am trying to delete a file from the server that I put
there (one file, not the whole directory). I am using unlink ($filename);
I did the path as a relative path as...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |