note 13190 deleted from features.file-upload by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 20:33:38 +0000 |
| Subject: | note 13190 deleted from features.file-upload by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25354@lists.php.net to get a copy of this message | ||
It was very useful to find the function fix_php_upload_bug, but then I thought, what if this bug
gets fixed, all my scripts would stop working with a future version. So I added a little function
php_detect_upload_bug, which should help. Also the "fix" discards the content-type
information, which I want, so the detection returns it (if available).
Hope it's useful for others:
I use it as
if ($type = detect...($file)) fix...($file)
function detect_php_upload_bug($tmp) {
$infile=fopen($tmp,"r"); // Open the file
$header=fgets($infile,255); //get the 1st line (netscape sometimes doesn't add a
Content-type line)
if (eregi("^Content-type: (.*)",$header,$regs) || strlen($header)>2) {
$content_type = $regs[1] ? $regs[1] : "application/octet-stream";
fclose($infile);
return trim($content_type);
}
fclose($infile);
return 0;
}