Re: [PHP] how to recognize CSV file?
On Fri, 2008-09-19 at 14:24 -0500, Afan Pasalic wrote: Eric Butera wrote: On Fri, Sep 19, 2008 at 3:14 PM, Afan Pasalic [EMAIL PROTECTED] wrote: Eric Butera wrote: On Fri, Sep 19, 2008 at 2:59 PM, Afan Pasalic [EMAIL PROTECTED] wrote: hi, I have form where administrator has toupload csv file to update dome data in mysql. I was trying to validate entered file but got some crazy stuff I don't understand: for the same uploaded csv file, in different browser I'll get different results: Windows machine and IE: $_FILES['UploadedFile']['type'] = 'text/plain' Windows machine and Firefox: $_FILES['UploadedFile']['type'] = 'application/octet-stream' Windows machine and Opera: $_FILES['UploadedFile']['type'] = 'comma-separated-values' Windows machine and Chrome: $_FILES['UploadedFile']['type'] = '' (doesn't show anything! empty?!?!!??) openSuse machine and Firefox: $_FILES['UploadedFile']['type'] = 'text/csv' openSuse machine and Opera: $_FILES['UploadedFile']['type'] = 'text/comma-separated-values' openSuse machine and Konqueror: $_FILES['UploadedFile']['type'] = 'text/csv' ok. what's CORRECT way to validate uploaded file? thanks. -afan Get the mime type of the uploaded tmp file, no what the browser sends. Fatal error: Call to undefined function mime_content_type() in /srv/www/... it looks like Mimetype is not installed on my server :-) Do you have fileinfo? It's a php5 pecl extension. Aside from that I'm not really sure. This is how I always test files since browser mime type is unreliable/spoofable. Fatal error: Call to undefined function finfo_open() in /srv/www/... no luck :-) If you don't have access to the functions, you could try reading the first line of the file to determine it's in the right format. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to recognize CSV file?
Ashley Sheridan wrote: On Fri, 2008-09-19 at 14:24 -0500, Afan Pasalic wrote: Eric Butera wrote: On Fri, Sep 19, 2008 at 3:14 PM, Afan Pasalic [EMAIL PROTECTED] wrote: Eric Butera wrote: On Fri, Sep 19, 2008 at 2:59 PM, Afan Pasalic [EMAIL PROTECTED] wrote: hi, I have form where administrator has toupload csv file to update dome data in mysql. I was trying to validate entered file but got some crazy stuff I don't understand: for the same uploaded csv file, in different browser I'll get different results: Windows machine and IE: $_FILES['UploadedFile']['type'] = 'text/plain' Windows machine and Firefox: $_FILES['UploadedFile']['type'] = 'application/octet-stream' Windows machine and Opera: $_FILES['UploadedFile']['type'] = 'comma-separated-values' Windows machine and Chrome: $_FILES['UploadedFile']['type'] = '' (doesn't show anything! empty?!?!!??) openSuse machine and Firefox: $_FILES['UploadedFile']['type'] = 'text/csv' openSuse machine and Opera: $_FILES['UploadedFile']['type'] = 'text/comma-separated-values' openSuse machine and Konqueror: $_FILES['UploadedFile']['type'] = 'text/csv' ok. what's CORRECT way to validate uploaded file? thanks. -afan Get the mime type of the uploaded tmp file, no what the browser sends. Fatal error: Call to undefined function mime_content_type() in /srv/www/... it looks like Mimetype is not installed on my server :-) Do you have fileinfo? It's a php5 pecl extension. Aside from that I'm not really sure. This is how I always test files since browser mime type is unreliable/spoofable. Fatal error: Call to undefined function finfo_open() in /srv/www/... no luck :-) If you don't have access to the functions, you could try reading the first line of the file to determine it's in the right format. could you please be more specific? I don't remember I ever saw file type when I was opening csv or txt or doc file? -afan Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to recognize CSV file?
On Sat, Sep 20, 2008 at 10:23 AM, Afan Pasalic [EMAIL PROTECTED] wrote: Ashley Sheridan wrote: On Fri, 2008-09-19 at 14:24 -0500, Afan Pasalic wrote: Eric Butera wrote: On Fri, Sep 19, 2008 at 3:14 PM, Afan Pasalic [EMAIL PROTECTED] wrote: Eric Butera wrote: On Fri, Sep 19, 2008 at 2:59 PM, Afan Pasalic [EMAIL PROTECTED] wrote: hi, I have form where administrator has toupload csv file to update dome data in mysql. I was trying to validate entered file but got some crazy stuff I don't understand: for the same uploaded csv file, in different browser I'll get different results: Windows machine and IE: $_FILES['UploadedFile']['type'] = 'text/plain' Windows machine and Firefox: $_FILES['UploadedFile']['type'] = 'application/octet-stream' Windows machine and Opera: $_FILES['UploadedFile']['type'] = 'comma-separated-values' Windows machine and Chrome: $_FILES['UploadedFile']['type'] = '' (doesn't show anything! empty?!?!!??) openSuse machine and Firefox: $_FILES['UploadedFile']['type'] = 'text/csv' openSuse machine and Opera: $_FILES['UploadedFile']['type'] = 'text/comma-separated-values' openSuse machine and Konqueror: $_FILES['UploadedFile']['type'] = 'text/csv' ok. what's CORRECT way to validate uploaded file? thanks. -afan Get the mime type of the uploaded tmp file, no what the browser sends. Fatal error: Call to undefined function mime_content_type() in /srv/www/... it looks like Mimetype is not installed on my server :-) Do you have fileinfo? It's a php5 pecl extension. Aside from that I'm not really sure. This is how I always test files since browser mime type is unreliable/spoofable. Fatal error: Call to undefined function finfo_open() in /srv/www/... no luck :-) If you don't have access to the functions, you could try reading the first line of the file to determine it's in the right format. could you please be more specific? I don't remember I ever saw file type when I was opening csv or txt or doc file? -afan Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could just try using fgetcsv. If that fails then it isn't a csv file. I always use get/put csv for working with these types. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to recognize CSV file?
hi, I have form where administrator has toupload csv file to update dome data in mysql. I was trying to validate entered file but got some crazy stuff I don't understand: for the same uploaded csv file, in different browser I'll get different results: Windows machine and IE: $_FILES['UploadedFile']['type'] = 'text/plain' Windows machine and Firefox: $_FILES['UploadedFile']['type'] = 'application/octet-stream' Windows machine and Opera: $_FILES['UploadedFile']['type'] = 'comma-separated-values' Windows machine and Chrome: $_FILES['UploadedFile']['type'] = '' (doesn't show anything! empty?!?!!??) openSuse machine and Firefox: $_FILES['UploadedFile']['type'] = 'text/csv' openSuse machine and Opera: $_FILES['UploadedFile']['type'] = 'text/comma-separated-values' openSuse machine and Konqueror: $_FILES['UploadedFile']['type'] = 'text/csv' ok. what's CORRECT way to validate uploaded file? thanks. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to recognize CSV file?
On Fri, Sep 19, 2008 at 2:59 PM, Afan Pasalic [EMAIL PROTECTED] wrote: hi, I have form where administrator has toupload csv file to update dome data in mysql. I was trying to validate entered file but got some crazy stuff I don't understand: for the same uploaded csv file, in different browser I'll get different results: Windows machine and IE: $_FILES['UploadedFile']['type'] = 'text/plain' Windows machine and Firefox: $_FILES['UploadedFile']['type'] = 'application/octet-stream' Windows machine and Opera: $_FILES['UploadedFile']['type'] = 'comma-separated-values' Windows machine and Chrome: $_FILES['UploadedFile']['type'] = '' (doesn't show anything! empty?!?!!??) openSuse machine and Firefox: $_FILES['UploadedFile']['type'] = 'text/csv' openSuse machine and Opera: $_FILES['UploadedFile']['type'] = 'text/comma-separated-values' openSuse machine and Konqueror: $_FILES['UploadedFile']['type'] = 'text/csv' ok. what's CORRECT way to validate uploaded file? thanks. -afan Get the mime type of the uploaded tmp file, no what the browser sends. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to recognize CSV file?
Eric Butera wrote: On Fri, Sep 19, 2008 at 3:14 PM, Afan Pasalic [EMAIL PROTECTED] wrote: Eric Butera wrote: On Fri, Sep 19, 2008 at 2:59 PM, Afan Pasalic [EMAIL PROTECTED] wrote: hi, I have form where administrator has toupload csv file to update dome data in mysql. I was trying to validate entered file but got some crazy stuff I don't understand: for the same uploaded csv file, in different browser I'll get different results: Windows machine and IE: $_FILES['UploadedFile']['type'] = 'text/plain' Windows machine and Firefox: $_FILES['UploadedFile']['type'] = 'application/octet-stream' Windows machine and Opera: $_FILES['UploadedFile']['type'] = 'comma-separated-values' Windows machine and Chrome: $_FILES['UploadedFile']['type'] = '' (doesn't show anything! empty?!?!!??) openSuse machine and Firefox: $_FILES['UploadedFile']['type'] = 'text/csv' openSuse machine and Opera: $_FILES['UploadedFile']['type'] = 'text/comma-separated-values' openSuse machine and Konqueror: $_FILES['UploadedFile']['type'] = 'text/csv' ok. what's CORRECT way to validate uploaded file? thanks. -afan Get the mime type of the uploaded tmp file, no what the browser sends. Fatal error: Call to undefined function mime_content_type() in /srv/www/... it looks like Mimetype is not installed on my server :-) Do you have fileinfo? It's a php5 pecl extension. Aside from that I'm not really sure. This is how I always test files since browser mime type is unreliable/spoofable. Fatal error: Call to undefined function finfo_open() in /srv/www/... no luck :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php