简体   繁体   中英

How to validate an uploaded csv/text file with php

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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM