-1

I'm trying to obtain the type of archive in php with strops and substr.

How can I find the position of the first point from the end of the name of the file?

$archive_name=$_FILES['uploaded_file']['name'];

$type=substr($archive_name, strpos(".") )  ?
Rudi Visser
  • 21,350
  • 5
  • 71
  • 97
  • tje answer to your question is strrpos (string reverse position :D) http://nl1.php.net/manual/en/function.strrpos.php Answers below are probably answers to the actual underlying problem. – hoppa Dec 21 '12 at 10:14

1 Answers1

3

You can use pathinfo for that.
But instead of relying on the filename I'd rather suggest using fileinfo

The functions in this module try to guess the content type and encoding of a file by looking for certain magic byte sequences at specific positions within the file. While this is not a bullet proof approach the heuristics used do a very good job.
VolkerK
  • 95,432
  • 20
  • 163
  • 226