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.
On the possibility that it's a protection problem (though it shouldn't be,
as I put it there in the first place), I did a
chmod($filename , "777");
The file doesn't delete from the server. Any ideas?
Thanks! 11 4457
"byteoart" <in**@byteoart. comwrote in message
news:Dc******** *************** *******@giganew s.com...
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.
On the possibility that it's a protection problem (though it shouldn't be,
as I put it there in the first place), I did a
chmod($filename , "777");
The file doesn't delete from the server. Any ideas?
Thanks!
One more thing that I forgot. If I do a var_dump(is_fil e($filename)); it
returns false, however using FTP, I see that the file is there, and another
page accesses it and brings it up, so it definitely is there.
..oO(byteoart)
>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.
On the possibility that it's a protection problem (though it shouldn't be, as I put it there in the first place), I did a chmod($filenam e, "777");
777 is a really bad idea. It makes the file writable for all people with
access to the server.
>The file doesn't delete from the server. Any ideas?
Any error messages? Is error_reporting set to at least E_ALL and
display_errors enabled?
Micha
"Michael Fesser" <ne*****@gmx.de wrote in message
news:av******** *************** *********@4ax.c om...
.oO(byteoart)
>>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.
On the possibility that it's a protection problem (though it shouldn't be, as I put it there in the first place), I did a chmod($filena me, "777");
777 is a really bad idea. It makes the file writable for all people with
access to the server.
I did that immediately before doing the unlink, so that shouldn't be a
problem.
>
>>The file doesn't delete from the server. Any ideas?
Any error messages? Is error_reporting set to at least E_ALL and
display_errors enabled?
There were no error messages, but I don't have error_reporting set. I will.
BTW, the is_file being false was operator error. It returns true. It was
during a couple of trials that it was looking at something else I
misinterpreted it. So, the is_file says it is there, but the unlink doesn't
delete it.
>
Micha
..oO(byteoart)
>"Michael Fesser" <ne*****@gmx.de wrote in message news:av******* *************** **********@4ax. com...
>> Any error messages? Is error_reporting set to at least E_ALL and display_erro rs enabled?
There were no error messages, but I don't have error_reporting set. I will.
On a development machine this should be done in the php.ini. The correct
values are
error_reporting = E_ALL|E_STRICT
display_errors = 1
Then check again if you get an error message on the unlink() call.
Micha
"Jensen Somers" <je****@sig.see .invalidwrote in message
news:Zc******** *************** *******@giganew s.com...
byteoart wrote:
>"byteoart" <in**@byteoart. comwrote in message news:Dc******* *************** ********@gigane ws.com...
>>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.
On the possibility that it's a protection problem (though it shouldn't be, as I put it there in the first place), I did a chmod($filena me, "777");
The file doesn't delete from the server. Any ideas?
Thanks!
One more thing that I forgot. If I do a var_dump(is_fil e($filename)); it returns false, however using FTP, I see that the file is there, and another page accesses it and brings it up, so it definitely is there.
It is possible this is caused by using a relative path to the file you
want to delete. Try using the full path. Using some globals you can
quickly find the root path of your web server and start from there.
I tried $path = dirname(__FILE_ _) . '/../images/6/image_001.JPG
aand it still didn't delete.
"Michael Fesser" <ne*****@gmx.de wrote in message
news:25******** *************** *********@4ax.c om...
.oO(byteoart)
>>"Michael Fesser" <ne*****@gmx.de wrote in message news:av****** *************** ***********@4ax .com...
>>> Any error messages? Is error_reporting set to at least E_ALL and display_error s enabled?
There were no error messages, but I don't have error_reporting set. I will.
On a development machine this should be done in the php.ini. The correct
values are
error_reporting = E_ALL|E_STRICT
display_errors = 1
Then check again if you get an error message on the unlink() call.
I don't have access to the server's php.ini. the hosting company has that
controlled.
"Jensen Somers" <je****@sig.see .invalidwrote in message
news:Zc******** *************** *******@giganew s.com...
byteoart wrote:
>"byteoart" <in**@byteoart. comwrote in message news:Dc******* *************** ********@gigane ws.com...
>>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.
On the possibility that it's a protection problem (though it shouldn't be, as I put it there in the first place), I did a chmod($filena me, "777");
The file doesn't delete from the server. Any ideas?
Thanks!
One more thing that I forgot. If I do a var_dump(is_fil e($filename)); it returns false, however using FTP, I see that the file is there, and another page accesses it and brings it up, so it definitely is there.
It is possible this is caused by using a relative path to the file you
want to delete. Try using the full path. Using some globals you can
quickly find the root path of your web server and start from there.
I tried $path = dirname(__FILE_ _) . '/../images/6/image_001.JPG
aand it still didn't delete.
"Michael Fesser" <ne*****@gmx.de wrote in message
news:av******** *************** *********@4ax.c om...
.oO(byteoart)
>>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.
On the possibility that it's a protection problem (though it shouldn't be, as I put it there in the first place), I did a chmod($filena me, "777");
777 is a really bad idea. It makes the file writable for all people with
access to the server.
>>The file doesn't delete from the server. Any ideas?
Any error messages? Is error_reporting set to at least E_ALL and
display_errors enabled?
I put in error_reporting (E_ALL). I tried uploading another file (which I
intended to delete). I got the following error message:
Warning: move_uploaded_f ile() [function.move-uploaded-file]: open_basedir
restriction in effect. File(C:\WINDOWS \TEMP\php63.tmp ) is not within the
allowed path(s):
However, using ftp, I can see that the file is there where it belongs and
the picture displays on the next page after the upload.
I then tried to delete the file and got this error message:
Warning: unlink(../images/6/image_007.JPG) [function.unlink]: Permission
denied
So, now I have three questions:
1 - Why did I get the error message on upload, yet it uploaded?
2 - Why didn't I get an error on chmod which appears immediately beofre the
unlink on which I got an error?
3 - Why did I get a permission denied problem for a file that I just put up
there/
byteoart wrote:
"Michael Fesser" <ne*****@gmx.de wrote in message
news:25******** *************** *********@4ax.c om...
>.oO(byteoart )
>>"Michael Fesser" <ne*****@gmx.de wrote in message news:av****** *************** ***********@4ax .com... Any error messages? Is error_reporting set to at least E_ALL and display_erro rs enabled? There were no error messages, but I don't have error_reporting set. I will.
On a development machine this should be done in the php.ini. The correct values are
error_reportin g = E_ALL|E_STRICT display_erro rs = 1
Then check again if you get an error message on the unlink() call.
I don't have access to the server's php.ini. the hosting company has that
controlled.
Then try this at the top of your script:
ini_set('displa y_errors','1');
ini_set('displa y_startup_error s','1');
error_reporting (E_ALL);
And try referencing the file with something like
$_SERVER['DOCUMENT_ROOT'] . '/images/6/image_001.JPG';
Jeff
> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 in a directory called "files".
With an administration form I can read all contents of the data.dat
file and select records to delete (one at a time).
So far so good.
|
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)){
|
by: rbt |
last post by:
Can someone detail the differences between these two? On Windows which
is preferred?
Also, is it true that win32api.DeleteFile() can remove the 'special'
files located in the 'special' folders only accessible by the shell
object such as Temporary Internet Files, etc.
Thanks!
|
by: ParK |
last post by:
<?php
$doc_root=("../il-uploads/"); //main dir
$file=$_FILES;
$fp = @fopen("../il-uploads/".$file,'r');//open it
@fclose($fp);
@unlink($doc_root.'/'.$file);
?>
not working :(
|
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 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...
| |
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 not workinng with the absolute path
@unlink("C:\htdocs\temp\0000058.txt")
the thing is I use unlink within a function called from different directories, so I use absolute path to make sure the path is correct. I've installed my application on...
|
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 "$filename <br>". "<a href="unlink('$filename');">Delete</
a>";
|
by: Coffee Pot |
last post by:
Thanks for any advice.
~ CP
|
by: kelvinwebdesigner |
last post by:
Hi everybody!
Im having trouble doing this task hope someone could help.
I still working on my project/app where user can upload a file a server, that then provide him with the link that can be shared for a certain period of time.
I want, using <option> tag, to make a user select the max time that he would like to share the image. For example when the user select 30 minutes, the php file get the server time, and then plus 30 minutes...
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |