note 13757 added to features.file-upload.php
| From: | nhyde at NOSPAM dot bigDrift dot com | Date: | Mon, 02 Jul 2001 04:46:51 +0000 |
| Subject: | note 13757 added to features.file-upload.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14851@lists.php.net to get a copy of this message | ||
For dealing with Mac and DOS/Windows files on *nix you'll want to replace all instances of a CR
and CRLF with LF. Here's a function to do just that:
/**
* name: replace_returns
* author: nhyde@NOSPAM.bigDrift.com
* description: replace DOS/Windows and Mac line endings with Unix-style LineFeeds
* param: filedata - string - data from the file
* returns: string with requested line endings
**/
function replace_returns ($filedata) {
if ( ereg(chr(13), $filedata) ) {
$temp_data = $filedata;
// replace CRLF combos for DOS/Windows files
$temp_data = ereg_replace(chr(13).chr(10), chr(10), $temp_data);
// replace the leftover CRs for Mac files
$temp_data = ereg_replace(chr(13), chr(10), $temp_data);
return $temp_data;
}
else {
return $filedata;
}
}
http://www.php.net/manual/en/features.file-upload.php