deleting file from desktop using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tinnumaverick
Forum Newbie
Posts: 7
Joined: Fri Oct 01, 2010 2:32 pm

deleting file from desktop using php

Post by tinnumaverick »

I want to delete a file named shiva.txt from desktop. I had tried
$filename = "filepath";
unlink($filename);

I had also tried by changing the mode of the directory to 0777. but no use still the file is not deleted.

any suggestions!!
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: deleting file from desktop using php

Post by DigitalMind »

It's impossible. PHP is a server side scripting language
tinnumaverick
Forum Newbie
Posts: 7
Joined: Fri Oct 01, 2010 2:32 pm

Re: deleting file from desktop using php

Post by tinnumaverick »

can i delete a file from server??
I want to delete a file from FOXML directory in this path

/srv/fedora/tomcat/webapps/formConfirm_1/WEB-INF/classes/FOXML

I had tried this code

<?php
$path="/srv/fedora/tomcat/webapps/formConfirm_1/WEB-INF/classes/FOXML";
$dh = opendir($path);
while ($temp = readdir($dh)) {
if ($temp!='.' && $temp!='..' && $temp!='.htaccess') chmod($temp,777); }

$filename = "/srv/fedora/tomcat/webapps/formConfirm_1/WEB-INF/classes/FOXML/shiva.xml";
unlink($filename);
?>

but no use...file not deleted... Is any thing else i am missing?? I am a newbie to php.
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: deleting file from desktop using php

Post by DigitalMind »

Sorry, I'm drunk at the moment and it's difficult to read your code without

Code: Select all

.
One of possible solutions is:
[syntax=php]
system("rm -rf $path");
[/syntax]
make sure $path contains just path (without any ;, &&, etc)
:)
tinnumaverick
Forum Newbie
Posts: 7
Joined: Fri Oct 01, 2010 2:32 pm

Re: deleting file from desktop using php

Post by tinnumaverick »

DigitalMind wrote:Sorry, I'm drunk at the moment and it's difficult to read your code without

Code: Select all

.
One of possible solutions is:
[syntax=php]
system("rm -rf $path");
[/syntax]
make sure $path contains just path (without any ;, &&, etc)
:)[/quote]

Thanks for your reply... but my acutal problem is 

I have an html form which has a delete button. whenever any user clicks the delete button, the file should be deleted from this location.

/srv/fedora/tomcat/webapps/formConfirm_1/WEB-INF/classes/FOXML/$filename

please suggest me any solutions... i am new to programming
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: deleting file from desktop using php

Post by DigitalMind »

Code: Select all

unlink($filename);
if it's not working, check apache process owner (usually www-data or www) writing permission for the file you're trying to delete
Post Reply