WikyBlog
Download

Home > Talk > attachments in link list

I wanted to have a link to a PDF file in the link list but it wasn't possible to add the URL of the attachment itself because the URL includes an & which gets translated to & at some point. I eventually had to put the file elsewhere on the server and add an external link. So, some way to add attached files to the link list would be nice.

I agree, it would be nice if PDF files could integrate more with the interface. Unfortunately, there are some concerns about the security involved with PDF files as well as the performance requirements and universal support. Ultimately, I think the ideal solution would be to parse PDF files into wiki or HTML syntax as they're uploaded. Not wanting to lead you, I should note there are a number of other pieces of WikyBlog being developed and it might be some time before different PDF handling is introduced (unless someone wants to take this on?). --Josh
Ok, I reread the original request and feel like a bit of a fool for my previous response. The link script does cleanse the url's twice and breaks any links with ampersands in them. I'll have that fixed for the next release. --Josh
Update In the mean time, you can add the attachment link as an external link, something like http://www.wikyblog.com/include/tool/Files.php?o=main&f=filename.pdf


I've patched include/tool/Files.php on my system to handle attached files properly. According to the php.net documentation, the function mime_content_type has been deprecated and replaced by the PECL finfo. My version of PHP doesn't have that, so I stuck with the mime_content_type and it works great.

    //send it
    function sendFile(&$path,&$name){
       $fp = fopen($path, 'rb');

       $name = str_replace('.wb~','.',$name);

       // send the right headers
       $mtype=mime_content_type($path);
       if ( $mtype != "" ) {
          header('Content-Type: ' . $mtype);
       }
       header('Content-Length: ' . filesize($path));
       header('Content-Disposition: attachment; filename='.$name);
       fpassthru($fp);
       exit;
   }

--glent

Thanks glent, I'll get that added and take a look at finfo. --Josh
Last modified 16:49 Wed, 14 May 2008 by Main. Accessed 51 times What Links Here share Share Except where expressly noted, this work is licensed under a Creative Commons License.