[pmwiki-users] Uploads question...

Patrick R. Michaud pmichaud at pobox.com
Wed Dec 20 16:16:46 CST 2006


On Wed, Dec 20, 2006 at 11:44:03AM -0500, The Editor wrote:
> Can someone explain exactly what I need to do to enable downloads from my site?
> 
> I have a page called Main.Downloads with all the files I want to make
> available.  The links look like this:  Attach:zap.php
> 
> I ftp's all my files to Uploads/Main/
> 
> In my config I have
> 
> $EnableUpload = 1;
> $UploadPrefixFmt = '';
> $UploadExts['php'] = 'scripts';

You need two pieces here.

First, $UploadExts is supposed to contain the mime-type for
the extension (and 'scripts' isn't a valid mime-type).  You
probably want to have

    $UploadExts['php'] = 'text/plain';

which means that PmWiki will send an HTTP response of
Content-type: text/plain when accessing the file with
?action=download.

However, since you aren't setting $EnableDirectDownload,
that means that PmWiki is generating links to access the .php
files directly via the server, and not via PmWiki.  By default,
most webservers are configured to execute files ending with .php,
not to return them to the browser to be displayed or downloaded.  
Thus, you have to tell the webserver to treat the .php file as 
something other than a real .php file.  In Apache this can often
be done with one of the following directives in the .htaccess file
for the uploads/ directory:

    # treat .php files as text files
    AddType text/plain .php

or

    # treat .php files as a file to be downloaded
    AddType application/octet-stream .php

Also note that IE sometimes totally ignores the Content-Type
header altogether and treats it as an HTML file no matter
what the server specifies.

> It seems to be working, but when I click on the file, I get a blank
> page.  Am I missing something?

You're getting a blank page because the webserver is executing the
.php script directly, and it's not producing any output.

Pm




More information about the pmwiki-users mailing list