On Mon, 29 May 2000, T. Wijnen wrote:

> Hi,
> 
> I posted a question about my problem a few days ago but the reply didn't
> help me, so:
> 
> I want to use the mgd_create_file function to attach a file to an
> article.
> 
> There should be 6 parameters, right? :
> *article : I understand
> *type : this should be the mime type? I really don't know what to fill
> in here, or what mime types exist.

Apache ships with a mimetypes file, I think. You could take samples from
that. 'locate mime.types' would be my guess.

> *name : what's this? Just a name to identify the file or is this the
> actual file name?

Whatever you like. Most of the time it's used for the 'screen name', the
name that the user/downloader will see.

> *content : don't know

Mostly used to store the actual location of the file

> *size : I can get this in PHP ($filename_size)

right.

> *md5 : this should be an encrypted key/string? why do I need it? How do
> I get it?

Given a form with

<INPUT NAME="userfile" TYPE="file">

You could for example do 

$fname = tempnam('/web/attachment', 'att'); 
copy($userfile, $fname); 
if ($userfile_type == '') $userfile_type = 'application/octet-stream';
$md5 = explode(' ', exec("md5sum $fname")); 
mgd_create_file($article, $userfile_type, $userfile_name, $fname,
$userfile_size, $md5[0]); 

All the fields in the file records are for your convenience only, they
mean nothing special to the Midgard core. You can get the values later and
use readfile to send the content to the browser.

> I uploaded a file test.txt to a tmd dir (/tmp/test.txt) with a html
> upload form, I heard you should first upload the file before you can use
> mgd_create_file. 

Right.

Emile


--
This is The Midgard Project's mailing list. For more information,
please visit the project's web site at http://www.midgard-project.org

To unsubscribe the list, send an empty email message to address
[EMAIL PROTECTED]

Reply via email to