Determine File Type of CSV
Posted: Mon Oct 10, 2005 8:17 am
Hello,
i have built an application that allows someone to upload "CSV" formatted files to be parsed so that the contents can be inserted into a databaste
The following code detects if the file uplaoded is a csv
The client is using MS Xcel as thier csv client application
The problem is i note that i get different file type readings when upload csv files.
Kendall
i have built an application that allows someone to upload "CSV" formatted files to be parsed so that the contents can be inserted into a databaste
The following code detects if the file uplaoded is a csv
Code: Select all
if(($filetype != 'application/vnd.ms-excel')){
$Msg .= 'Error: Could not Upload - '.$filename.' Only CSV '.$filetype.' formats are accepted';
}else{
if(file_exists($filename)){
@unlink($filename);
}
move_uploaded_file( $tmp_name, $filename );
}The problem is i note that i get different file type readings when upload csv files.
Which is the default csv file type to be using...note that the client is using excel 2003 and converting xecel spredsheet into comma delimited csv file formatapplication/octet-stream
application/vnd.ms-excel
text/csv
text/comma-separated-values
Kendall