syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bbvic
Forum Newbie
Posts: 1
Joined: Fri Aug 03, 2007 8:37 am

syntax

Post 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;
}
Last edited by bbvic on Fri Aug 03, 2007 8:58 am, edited 2 times in total.
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

Whats your question?
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Post 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. :)
Post Reply