Welcome Guest, Not a member yet? Register   Sign In
file delete problem
#1

[eluser]rubai[/eluser]
hi there
i am trying to delete one file from localhost.
but it fails.
i write:
Code:
delete_files($_SERVER['DOCUMENT_ROOT'].'/project/uploads/'.$exists_image);
where $exists_image is the file name.
but if i print the code it shows the right path.
for example
Code:
C:/apachefriends/xampp/htdocs/project/uploads/image.jpg
is my code wrong?
#2

[eluser]座頭市[/eluser]
You might want to read the documentation a little more carefully...
#3

[eluser]rubai[/eluser]
Quote:You might want to read the documentation a little more carefully…

thanks. but i wrote this post after reading the documentation and several tries.
#4

[eluser]座頭市[/eluser]
Read it again.
#5

[eluser]woopsicle[/eluser]
Ok, I think rather than repeatedly saying 'RTFM' it might be worth taking the 1 minute of my time to actually help this fellow.

The delete_files function doesn't use the second parameter as you are trying to use it.
The second parameter is TRUE or FALSE, where true means it will recursively delete all sub folder/files as well.

You might want to look an unlink (http://au2.php.net/manual/en/function.unlink.php) as this is more suitable to delete a single file.
#6

[eluser]座頭市[/eluser]
<sigh> Apparently you're not familiar with or don't subscribe to the give a man a fish/teach a man to fish theory. Tongue
#7

[eluser]woopsicle[/eluser]
no i do.. but if he/she asks twice.. insisting they have read the manual.. then clearly they are fundamentally missing something when reading the manual. i.e. read a sentence and misinterpreting it... reading it 100 more times isn't going to change it.
#8

[eluser]rubai[/eluser]
thanks. it works nicely.
may be delete_files() cannot delete single file.
but in a previous post one says:
Quote:Hey. I’m trying to write some code that deletes an image from a server. I’m using this code but for some reason it won’t delete the file:

delete_files(base_url().'images/'.$type.'/'.$info[0]->image);

Now the URL works fine, if I print an <img> tag with that URL then it displays the image. But for some reason it just won’t delete it
and others reply him. for this i think it is possible to use delete_files() for deleting single file.

to 座頭市:
if you not interested then must ignore posts.




Theme © iAndrew 2016 - Forum software by © MyBB