473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Confused by unlink problem!

Hi Folks

I'm trying to delete a file.

unlink('../images/photos/1967_GT_500_Shelby_Mustang.jpg');
That works

$fm = "../images/photos/1967_GT_500_Shelby_Mustang.jpg";
unlink($fm);
That doesn't. Why?

I need to pass the file name as a variable as it's the result of a mysql
query.

--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk
Jul 17 '05 #1
7 4364
On Sun, 04 Jan 2004 21:36:43 +0000, 3A Web Hosting wrote:
Hi Folks

I'm trying to delete a file.

unlink('../images/photos/1967_GT_500_Shelby_Mustang.jpg'); That works

$fm = "../images/photos/1967_GT_500_Shelby_Mustang.jpg"; unlink($fm);
That doesn't. Why?

I need to pass the file name as a variable as it's the result of a mysql
query.

What error do you get Colin? I've just finished a project that does
exactly that (actually concatenated string of vars) with no problems.

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

Jul 17 '05 #2
Hi Ian
What error do you get Colin? I've just finished a project that does
exactly that (actually concatenated string of vars) with no problems.


I get :-

Warning: unlink(../images/photos/1967_GT_500_Shelby_Mustang.jpg): No
such file or directory in
/var/www/html/gallery/admin/killphotos.php on line 87

The file is definately there. It get's deleted without problem if I use
the path instead of a variable.
--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk
Jul 17 '05 #3
"3A Web Hosting" <in**@3awebhosting.co.uk> wrote in message
news:3F***************@3awebhosting.co.uk...
Hi Ian
What error do you get Colin? I've just finished a project that does
exactly that (actually concatenated string of vars) with no problems.


I get :-

Warning: unlink(../images/photos/1967_GT_500_Shelby_Mustang.jpg): No
such file or directory in
/var/www/html/gallery/admin/killphotos.php on line 87

The file is definately there. It get's deleted without problem if I use
the path instead of a variable.
--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk


Ok, I know this is weird,

but do another action on the variable, such as

print "file :$fm:\n";
print "size:".filesize($fm)."\n";

just to see if it breaks in other functions as well.

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #4
Hi
Ok, I know this is weird,

but do another action on the variable, such as

print "file :$fm:\n";
print "size:".filesize($fm)."\n";

just to see if it breaks in other functions as well.


Just tried that. I get the following:-

file :../images/photos/1967_GT_500_Shelby_Mustang.jpg:
Warning: filesize(): Stat failed for
.../images/photos/1967_GT_500_Shelby_Mustang.jpg (errno=2 - No such file
or
directory) in /var/www/html/gallery/admin/killphotos.php on line 82
size:

--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk
Jul 17 '05 #5
Hi

Well, I've just tried running it on a different server and it worked.
Weird!

--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk
Jul 17 '05 #6
"3A Web Hosting" <in**@3awebhosting.co.uk> wrote in message
news:3F***************@3awebhosting.co.uk...
Hi

Well, I've just tried running it on a different server and it worked.
Weird!

--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk

try the full path instead of the ../

just a guess

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #7
It is perfectly fine to pass variable containing filename to *unlink*
function.
And it should work, look for error in filename (may be unnecessary
space or some other char).

--
Rahul
3A Web Hosting <in**@3awebhosting.co.uk> wrote in message news:<3F***************@3awebhosting.co.uk>...
Hi Folks

I'm trying to delete a file.

unlink('../images/photos/1967_GT_500_Shelby_Mustang.jpg');
That works

$fm = "../images/photos/1967_GT_500_Shelby_Mustang.jpg";
unlink($fm);
That doesn't. Why?

I need to pass the file name as a variable as it's the result of a mysql
query.

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric | last post by:
Hello, I created a form to upload files. The formfield contents are stored as records in an Ascii file "data.dat"; for reasons I am not using a MySql database. The upoaded file itself is stored...
1
by: Alexandru | last post by:
Hello fellows. i have a problem with unlink function. if i'm trying to use uplink like this: unlink("../home/meks_party.jpg"); i got the message: Warning: unlink(../home/meks_party.jpg): No...
1
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...
10
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,...
4
by: nitinpatel1117 | last post by:
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...
1
by: fcaserio | last post by:
Is there any PHP.INI config or windows permission (win 2003) that can prevent PHP to unlink files with the system path? unlink works with relative path: @unlink("temp\0000058.txt") but it is...
15
by: Morteneistrom | last post by:
Im a complete n00b at PHP so please forgive me if this i a stupid question Why wont the following work. PHP Code: <?php foreach (glob('../images/profil/*.jpg') as $filename) { echo...
11
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...
18
by: Coffee Pot | last post by:
Thanks for any advice. ~ CP
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
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 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.