hi guys, is this possible with apache http server? i wish to delete a local xml file upon recieving a post request from an another computer.
+1
A:
You could do that with PHP (or any other sript language, your apache server supports).
<?php
error_reporting(E_ALL ^ E_NOTICE);
if ($_POST['var']) unlink ('/path/to/file.xml');
?>
But you have to make sure then the POST request is sent to this PHP file. Do you know the URL the POST is send to?
JochenJung
2010-07-23 06:27:36
yeah, actually im working with two PCs now, so the URL for the POST is sent to the one that is hosting the apache server , <http://ipaddress/file.xml>
Kenneth
2010-07-23 08:19:12
Is http://ipaddress/file.xml the URL you access via POST? If you like to use the PHP approach you should rather access http://ipaddress/file.php if that is possible.
JochenJung
2010-07-23 08:31:59
oh i see. alright i'll try it
Kenneth
2010-07-23 08:34:39
what does var in ($_POST['var']) mean
Kenneth
2010-07-23 08:37:28
If you access http://ipaddress/file.php?var=file.xml then $_POST['var'] will be 'file.xml'
JochenJung
2010-07-23 09:05:42
im getting a Notice: Undefined index: var in C:\phptests\Test.php on line 2 when i try http://127.0.0.1/Test.php?var=file.xml
Kenneth
2010-07-23 09:18:59
my php file only has that 3 lines of code that u posted tho :\
Kenneth
2010-07-23 09:19:21
You can ignore notices in PHP. I modified my code above, so this notice will not be shown anymore: error_reporting(E_ALL ^ E_NOTICE); Which file is it you like to unlink? You shuold replace '/path/to/file.xml' by that files path
JochenJung
2010-07-23 09:45:23
I really hope you're careful to avoid allowing arbitrary deletion. Either that or let us POST to http://where.ever/file.php?var=/etc/passwd and kiss your OS goodbye. :-)
Donal Fellows
2010-07-23 09:47:31