Page 1 of 1

syntax

Posted: Fri Aug 03, 2007 8:41 am
by bbvic
I have a file name as below.
I want to check a file name before it uploads.


----------------------------------
file name is test12345_11.txt and it keeps the first four strings and file name..
12345_11 will be changable
-----------------------------------

this is a code that i am trying.
Can you check the syntax and is it correct way?

if(substr(basename($_FILES['upload']['name']),0,3) != 'test') && substr(basename($_FILES['upload']['name']),-4) != '.txt'))
{
echo '<br><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">';
exit;
}

Posted: Fri Aug 03, 2007 8:43 am
by guitarlvr
Whats your question?

Posted: Fri Aug 03, 2007 8:52 am
by Chalks
I think he's asking if

Code: Select all

substr(basename($_FILES['upload']['name']),0,3)
is correctly coded.


I'd recommend trying it.... Plus I don't know. :)