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

Recommended Answers

All 4 Replies

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

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

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)

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

Try them.....!

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? :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.