Mac WWW upload error FIX (in PERL)

From: Date: Sun, 01 Oct 2000 21:55:11 +0000
Subject: Mac WWW upload error FIX (in PERL)
Groups: php.general 
Request: Send a blank email to php-general+get-18223@lists.php.net to get a copy of this message
Greetings, I found the following bit of code for removing the data fork from a file uploaded via www by a Mac so that the file uploaded is usable. Trouble is it's in PERL and I want to run it directly from PHP. Is there anyone out there that can rewrite it in PHP so we can all use it :) Here's the info: The following subroutine "extracts the data fork (what most people would call the real file contents) from the middle of the macbinary encapsulation (which also includes the resource fork and some metadata like type and creator). I got this code off the net, so if it's not entirely accurate, I'm sure one of you will tell me. Basically, the first 128 bytes appears to be a header, and bytes 84 through 87 appear to be a network-order integer value of how many bytes immediately following the header constitute the datafork. So, with the right manipulation, I'm done." sub strip_fork_from_fh { my $fh = shift; my $len = read $fh, (my $buf), 128; # read the header die "short read: $len" unless $len == 128; my $bytes = unpack("x83N", $buf); # get datafork length read $fh, $buf, $bytes; $buf; } You can view the article I found the code from at http://www.stonehenge.com/merlyn/WebTechniques/col46.html

« previous php.general (#18223) next »