Ashwin Mekala
Ashwin Mekala

Reputation: 13

Why can't I use # ( Number Sign ) as a value in POST ( php page )

I have a php project where I have to pass file name as POST request to delete files in web server.But while I pass file name containing # ( Number Sign ) it is unable to get correct file name which resulting error.

here is my simple php script

<?php
$file = $_GET["file"];
if (!unlink("upload/".$file))
  {
  echo ("Error deleting $file");
  }
else
  {
  echo ("Deleted $file");
  }
?>

Upvotes: 1

Views: 123

Answers (1)

Quentin
Quentin

Reputation: 943650

Because:

  • You are trying to read from $_GET not $_POST and
  • # has special meaning in URIs and must be percent encoded as %23 if you want to express it as data

Upvotes: 5

Related Questions