GET_id not working in UnLink (delete file)

Discuss coding issues, and scripts related to PHP and MySQL.
User avatar
JanMolendijk
Posts:282
Location:Holland Rotterdam

GET_id not working in UnLink (delete file)

I searching for an hour for a solution; unlink seems not to work with GET id

Code: Select all

<?php   
$id = (int) $_GET['id'];

echo  $_GET['id'];

$file = fopen("'.$_GET['id'].'.txt","w");
echo fwrite($file,"Succesfully written document ticket);
fclose($file);

unlink("'.$_GET['id'].'.txt");
?>
Hope Coursesweb can help me out.

JanMolendijk Posts:282
Here is an answer `o god after 2 hours shame on me for this one`

Code: Select all

<?php
$file_pointer = $_GET[file].'.txt';
if (!unlink($file_pointer)) {
   echo ("File can’t be deleted!");
} else {
   echo ("File deleted!");
}
?>

Similar Topics