0

Hi all

I have build an small personal form to delete images. (personal use only)
The respons I keep getting is "file not found..."

I use the script locAL (WAMP)

THIS IS THE FORM:

<form name="form" method="post" action="delete.php" >
  <label>delete
    <input type="text" name="delete" id="delete" >
  </label>
  <label>
    <input type="submit" name="send" id="submit"  >
  </label>
</form>

DELETE PHP

<?php

ini_set('display_errors',1); 
error_reporting(E_ALL | E_STRICT); 

if (   $_SERVER['REQUEST_METHOD'] == 'POST'
    && isset($_POST['delete']) && trim($_POST['delete']) != '') {



  if (file_exists($_SERVER['DOCUMENT_ROOT'].'/upload/'.$_POST['delete'])) {
       unlink();
    } 
    else {
        echo 'file not found....';
    } 
}
else {
   echo 'fill in something';
}      
?>

I have searched and tried some new code.

The files in upload are named "fashion.jpg" and "dog.gif"
I tried it with and without .jpg and .gif. but the only respons "file not found..
Thanks for the feedback

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by reminem
0

Okay what I would suggest doing is where you are echoing out the error message "file not found..." under that add the following line: echo "<br />" . $_SERVER['DOCUMENT_ROOT'] . "/upload/" . $_POST['delete']; This should bring a new line displaying the internal file system path that the system is looking for.

0

Hi Froger93
Thanks for the reply

This is the error message
C:/wamp/www/test_script/upload/fashion.jpg
Warning: unlink(fashion.jpg) [function.unlink]: No such file or directory in C:\wamp\www\test_script\delete.php on line 12

the backslashes are different
Is this possible to change an how?

thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.