tags:

views:

24

answers:

1

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
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
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
oh i see. alright i'll try it
Kenneth
what does var in ($_POST['var']) mean
Kenneth
If you access http://ipaddress/file.php?var=file.xml then $_POST['var'] will be 'file.xml'
JochenJung
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
my php file only has that 3 lines of code that u posted tho :\
Kenneth
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
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