0

how we can delete a uploaded from its source folder when it is deleted from database
pls tell me

5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by richieking
0

Ok
In this case you can take the file name from datebase say "file_name.ext" and do as follow

<?
unlink("file_name.ext")
?>
0

Use the unlink() function.

Syntax is unlink('filename.ext'); Example:

<?php
  
  unlink('file.txt'); //Delete "file.txt" from the current folder.
  unlink('../file.txt'); //Delete "file.txt" from the parent folder.
  unlink('texts/file.txt'); //Delete "file.txt" from the "texts" folder.
  unlink('../texts/file.txt'); //Delete "file.txt" from the "texts" folder within the parent folder.

  $filepath = '../texts/file.txt';

  unlink($filepath); //Deletes the specified file in the "$filepath" variable

?>

I hope that helps. (I think I may have overdone it with the examples. :P)

0

Ya these are the ways by which you can delete a file from its destination

Try them.....!

0

watch this simple steps.

$foo="Delete from foo where file_path='$fPath' and name='$name'";
$d= mysql_query($foo);

if($d){
unlink("/path to file/$fPath");
}

you get the idea? :)

Edited by richieking: n/a

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.