Page 1 of 1

deleting file from desktop using php

Posted: Fri Oct 01, 2010 2:40 pm
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!!

Re: deleting file from desktop using php

Posted: Fri Oct 01, 2010 2:43 pm
by DigitalMind
It's impossible. PHP is a server side scripting language

Re: deleting file from desktop using php

Posted: Fri Oct 01, 2010 3:19 pm
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.

Re: deleting file from desktop using php

Posted: Fri Oct 01, 2010 3:32 pm
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)
:)

Re: deleting file from desktop using php

Posted: Fri Oct 01, 2010 4:35 pm
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

Re: deleting file from desktop using php

Posted: Fri Oct 01, 2010 5:37 pm
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