Re: [PHP] MAC file upload

2002-04-08 Thread Erik Price


On Saturday, April 6, 2002, at 11:44  AM, Shane McBride wrote:

 Hello,

 I am able to upload and download Macintosh files but they seem to lose 
 their
 MIME type or extensions. I'm not sure what it is. I'm not a Mac dude.

 When you download the file It loses the file association. It's for a 
 company
 I do work for that uses a lot of .ai and .psd files.


 Any ideas on this?

You're possibly losing the resource fork of the files you are uploading, 
because the server is not an HFS+ filesystem.  To the best of my 
knowledge there is nothing you can do about this via PHP, but there are 
probably tricks (like AppleScript) that you could use as a workaround, 
such as encoding the files in some transport-friendly format before 
uploading and decoding them upon download.

Erik





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MAC file upload

2002-04-08 Thread Rénald CASAGRAUDE


Le lundi 8 avril 2002, à 03:45 PM, Erik Price a écrit :

 When you download the file It loses the file association. It's for a 
 company
 I do work for that uses a lot of .ai and .psd files.

Hi !

Have you tried with :

$filesize = filesize($your_file);

header(Content-type: .$your_mime_type);
fread($your_file, $filesize);

exit();


R.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] MAC file upload

2002-04-08 Thread Rance Hall

Shane,

Eric is absolutely right, you are losing the resource fork of your mac binaries when 
you upload them.

(If you don't know, on a Mac, the binary file has to parts, the data, and the 
association with an application (or resource) that created the file.  This is done so 
that Mac file names don't need an extension)

Most server systems (except Mac of course) don't know how to handle a resource fork, 
so they drop it.  The standard Mac work around is to convert the binary file to a text 
format called binhex (.hqx filename extension) upload the .hqx file to the server and 
then reconvert it back once downloaded to a Mac that knows what to do with the 
resource fork information.

This process can be automated with apple script if you like,  but, if you ever want 
another machead to help you diagnose problems, stick to this layout, that way they 
know what you are doing.

Rance

Rance Hall
308.238.2455
Internal Office Extensions: 2455 or 6655
PC Programmer, The Buckle, Inc.
[EMAIL PROTECTED]


-Original Message-
From: Erik Price [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 08, 2002 8:46 AM
To: Shane McBride
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] MAC file upload



On Saturday, April 6, 2002, at 11:44  AM, Shane McBride wrote:

 Hello,

 I am able to upload and download Macintosh files but they seem to lose 
 their
 MIME type or extensions. I'm not sure what it is. I'm not a Mac dude.

 When you download the file It loses the file association. It's for a 
 company
 I do work for that uses a lot of .ai and .psd files.


 Any ideas on this?

You're possibly losing the resource fork of the files you are uploading, 
because the server is not an HFS+ filesystem.  To the best of my 
knowledge there is nothing you can do about this via PHP, but there are 
probably tricks (like AppleScript) that you could use as a workaround, 
such as encoding the files in some transport-friendly format before 
uploading and decoding them upon download.

Erik





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MAC file upload

2002-04-08 Thread Justin French

Hi all,

Forgive me for coming in a little late on this.  I don't really have any
solutions... more like a set of comments, which may be usefull.


Macs have a compression/decompression program called Stuffit (Drop stuff for
compression, Stuffit Expander for decompression).  This software is
free/shareware, and in all my years on a mac (6), I've never known a mac
user to not have *at least* Stuffit Expander.

It works simularly to ZIP on Windows machines, preserving a file or bunch of
files, folders, etc etc perfectly.  So, for starters, it will preserve the
way that each file associates itself with it's program.

As long as these files will *only* be used by Mac users, then you could
require everything in .sit (stuffit) format.


As a side issue, Stuffit expander decompresses HEAPS of compressed file
types, from *nix, Win, Mac OS, etc.

.sit (stuffit native)
.cpt
.pkg
.lha
.zip
.arc
.gzip
.gz
.tar
.z
.hqx
.bin
.pf
.uu


So, if your user base is both PC and mac, you may be able to settle on a
compressed format(s) which the majority of Win and Mac users can open.

Stuffit expander is also available for PC, although you *don't* want to
force millions of PC users to run Stuffit... however if your user group is
more controlled (say one office of staff), this may be an option.


FILE TYPES:

Just for interests sake, I opened up a Iustrator 8.0 file (.ai) in a text
editor, and grabbed the first three lines for you:

%!PS-Adobe-3.0 
%%Creator: Adobe Illustrator(R) 8.0
%%AI8_CreatorVersion: 8

It's possible that you could establish file types by looking at the files
themselves.


I'd be more inclined to do a test on the file name itself.  If it doesn't
have an expected extension (.psd, .gif, .ai, .jpg, etc), you could reject it
and ask them to append the file type, or better still ask them from a
pull-down list after upload, and alter the file name yourself.


The other catch in the Mac world is that I can name a PSD file
something.gif, or even something.html, so relying on the extension alone is
not going to be too acurate.


I do commonly have problems with file-association (double clicking on a pds
file opening photoshop), if the file has come from a non-mac server, or has
come down through the web, or has been mangled by browser mime-types etc
etc.  Worse still, users' mime-types in thier browser can be set waay
different.  For example, IE5's default for opening .psd files is Quicktime,
not Photoshop!!


So, it how much pain you go through to get the file types and association
right depends on:

- who your target users (recievers) are
- what system they run
- how savvy they are
- if your user base is a small controlled group (like 5 users in a pre-press
shop) or open (like any user on the web)


I'd be trying to establish the file type by looking for an extension,
looking at the file itself or asking the user for the file type (or all
three!!).


Asking your mac users to only upload in .sit format may indeed help keep the
files preserved as is, but may provide additional problems, if PC users
wish to use the files.



Sorry for the long email, hope it was some help.

Justin French
-
http://indent.com.au
http://soundpimps.com
-






on 09/04/02 12:59 AM, Rance Hall ([EMAIL PROTECTED]) wrote:

 Shane,
 
 Eric is absolutely right, you are losing the resource fork of your mac
 binaries when you upload them.
 
 (If you don't know, on a Mac, the binary file has to parts, the data, and the
 association with an application (or resource) that created the file.  This is
 done so that Mac file names don't need an extension)
 
 Most server systems (except Mac of course) don't know how to handle a resource
 fork, so they drop it.  The standard Mac work around is to convert the binary
 file to a text format called binhex (.hqx filename extension) upload the .hqx
 file to the server and then reconvert it back once downloaded to a Mac that
 knows what to do with the resource fork information.
 
 This process can be automated with apple script if you like,  but, if you ever
 want another machead to help you diagnose problems, stick to this layout, that
 way they know what you are doing.
 
 Rance
 
 Rance Hall
 308.238.2455
 Internal Office Extensions: 2455 or 6655
 PC Programmer, The Buckle, Inc.
 [EMAIL PROTECTED]
 
 
 -Original Message-
 From: Erik Price [mailto:[EMAIL PROTECTED]]
 Sent: Monday, April 08, 2002 8:46 AM
 To: Shane McBride
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] MAC file upload
 
 
 
 On Saturday, April 6, 2002, at 11:44  AM, Shane McBride wrote:
 
 Hello,
 
 I am able to upload and download Macintosh files but they seem to lose
 their
 MIME type or extensions. I'm not sure what it is. I'm not a Mac dude.
 
 When you download the file It loses the file association. It's for a
 company
 I do work for that uses a lot of .ai and .psd files.
 
 
 Any ideas on this?
 
 You're possibly losing the resource fork of the files you are uploading,
 because

Re: [PHP] MAC file upload

2002-04-08 Thread Miguel Cruz

On Tue, 9 Apr 2002, Justin French wrote:
 %!PS-Adobe-3.0 
 %%Creator: Adobe Illustrator(R) 8.0
 %%AI8_CreatorVersion: 8
 
 It's possible that you could establish file types by looking at the files
 themselves.

  man file
  man magic

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MAC file upload

2002-04-06 Thread Miguel Cruz

On Sat, 6 Apr 2002, Shane McBride wrote:
 I am able to upload and download Macintosh files but they seem to lose
 their MIME type or extensions. I'm not sure what it is. I'm not a Mac
 dude.
 
 When you download the file It loses the file association. It's for a
 company I do work for that uses a lot of .ai and .psd files.

Macs running OS=9 don't natively rely on extensions to keep track of file
types; something ending in .psd can be a Word file, .doc can be a PDF,
.pdf can be a JPEG, what have you. The name is just the name, nothing
more, nothing less.

Instead, they rely on metadata stored in the directory entry (parallel to 
name, creation date, etc.) that identifies the application that created 
the file and the data type contained inside. 

When you transfer a file between a Mac and another system, it's up to the
application doing the transferring to reconstruct the data type info. Many
apps do it based on extension, but not all of them know a huge number of
extensions (they may know .gif, .html, .txt, etc.). And the MIME type you
send may override their guess. You should find out what MIME type you are 
sending and what 4-character Type and Creator info is getting saved; 
that'll help immensely in troubleshooting.

Macs running OSX are willing to use extensions in addition to the Mac
style system.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php