473,732 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unlink - permission denied

111 New Member
Hi

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

Warning: unlink(UsedNOS2 00704191.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 12829
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
Jun 5 '07 #2
nitinpatel1117
111 New Member
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 New Member
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 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!
Jun 6 '07 #5

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

Similar topics

4
14567
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) in /usr/local/www/vhosts/publicdomainsoftware.org/htdocs/ppUtilityCode/mcAdminImages.php on line 254 I don't get it. If PHP uploads the file, how can PHP not have the
1
3727
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); chmod($XMLPath.$file, 0777); chmod($XMLPath.$successpath, 0777);
5
6474
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 $logPath/$logFileName should delete the log file, however, it never deletes it due to permissions error. However, upon checking the file properties I find this:
1
2798
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 upload on my local machine using simple stuff like: <?php if(file_exists($new_file_name)){
10
7604
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, which is then processed and the contents are inserted into a new file, created in PHP, onto the server.
6
16775
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
0
3405
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 installed same application on another server Win 2003 R2 Std (No Active Directory). On that server I get “Permission denied” using the following code (used to zip folder content).
0
1219
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 installed same application on another server Win 2003 R2 Std (No Active Directory). On that server I get “Permission denied” using the following code (used to zip folder content). set WshShell = server.createobject("wscript.shell")
11
4463
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 follows: .../images/6/image_001.JPG I did a scandir $files = scandir("../images/6"); The print_r ($files); shows that the file is one of the files present.
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9235
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.