3

I am using the codeigniter and I managed to create an upload system that checks for extension and size.

What I want to do now is to check if those files are tab separated and have a specific number of columns.

Anyone can point me in the right direction?

Thanks.

biojl
  • 1,060
  • 1
  • 8
  • 26
  • How about reading this first: http://stackoverflow.com/questions/2450345/how-to-validate-csv-file – Sudhir Bastakoti Mar 19 '12 at 09:23
  • I read it before posting the question, it only contains suggestions, but not a straight way to do it. Besides, the approach is different. – biojl Mar 19 '12 at 09:31

2 Answers2

3

Read the first line and use preg_split to split it based on the tab character.

The size of array returned should match the expected number of columns. If not, then the uploaded file is not valid.

sikander
  • 2,286
  • 16
  • 23
1

Use a custom callback function for the form validation. Help on this can be found here.

Help for checking tab delimited here, and number of columns here.

Community
  • 1
  • 1
Rooneyl
  • 7,802
  • 6
  • 52
  • 81