Jump to content

Verifying music link extensions


Porl123

Recommended Posts

I dont get why you dont want to use substr() function.

 

You could use regular expressions to get extension of the file.

 

But, if you dont want to use substr() here is a way to do it

 

$filename = 'something.wav';
$fl = strlen($filename); // File length
$fileextension = $filename[$fl] . $filename[($fl-1)] . $filename[($fl-2)];
if ( $fileextension == 'wav' ) {
echo 'Valid file extension';
}

 

The downside to this is that the person could just change the extension of the file with a malicious exe inside.

I dont get why you dont want to use substr() function.

 

You could use regular expressions to get extension of the file.

 

But, if you dont want to use substr() here is a way to do it

 

$filename = 'something.wav';
$fl = strlen($filename); // File length
$fileextension = $filename[$fl] . $filename[($fl-1)] . $filename[($fl-2)];
if ( $fileextension == 'wav' ) {
echo 'Valid file extension';
}

 

The downside to this is that the person could just change the extension of the file with a malicious exe inside.

 

I don't know why on earth someone would choose that over substr but regardless, you made a small fubar in judgement.  strlen returns length of string but elements start at 0 not 1 so it would be $fl-1,$fl-2,$fl-3 not $fl,$f-1,$fl-2

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.