Using Attach, e.g. Attach:filewithan.extensionthatdoesnotexist PmWiki generates an upload link. It seems to me that if the extension is disabled PmWiki should not generate an upload link.


Footer with attachments listed for each page

If you enable per-page uploads on your wiki, you can add to the YourGroup.GroupFooter page (replacing 'YourGroup' with the name of your group) (:attachlist {*$Name}:) to show all attachments of each page in the page's footer. See page directives#attachlist, group footers and page variables.

Is it possible to support the markup to set image size

[[https://example.com | %width=99px%Attach:image.jpeg%%]] (which doesn't work) as well as
%width=99px%[[https://example.com | Attach:image.jpeg]]%% (which does)
simon May 23, 2020, at 04:26 AM

No, Embedded pictures markup is particular and only processed inside links when the link text contains nothing but a link to a picture (with possible title/alt). Please use the second example which works. Alternatively, style that picture with CSS, there are several ways to do it, eg below. --Petko May 23, 2020, at 06:37 AM

/* all pictures inside links */
#wikitext a img { width: 99px; }

/* only "image.jpeg" inside links */
#wikitext a img[src$="image.jpeg"] { width: 99px; }

I'd like to upload *.ics-files. If I change upload.php, it will be overwritten by the next update. Is there another way?

Absolutely, see UploadsAdmin#newuploadfiletypes. For iCalendar files, the line in config.php would be:

  $UploadExts['ics'] = 'text/calendar'; 

You should never have to modify core files with PmWiki, everything can be configured, enabled or changed from config.php -- if it cannot, we'll add it. --Petko December 16, 2019, at 11:49 AM

For images (e.g., [[Attach:image.jpg"mouse over tool" | Caption text ]]) how is a caption text specified in the same way as described on the images page? The example as shown does not seem to work

simon April 28, 2019, at 10:08 AM

Use Attach:image.jpg"mouse over tool" | Caption text --Petko

After you upload something, you are redirected to a URL like "Main/HomePage?action=upload&uprname=some_image.jpg&upresult=success". Is there a way to just have it redirect back to whatever page you were on (like Main/HomePage) with no "?action"?

You can define your own global $UploadRedirectFunction that will be called with the pagename and the default URL. If the URL ends with "&upresult=success" your function can redirect to $pagename, otherwise to the URL (there will be messages about why the upload failed). Note that a successfully uploaded file may be renamed in many cases, for example uploads can only have lowercase extensions, then the ?action=upload page will show the new filename (this cannot be detected from inside $UploadRedirectFunction). --Petko August 28, 2018, at 05:51 AM

There is a new type of attribute to html5, called 'integrity'. Usually it has the md5sum of the file to automagically check for integrity. If the integrity check fails, the browser won't allow you to download the file. Why I believe this is somewhat important? Because some of the files were altered before some changes that where made to PmWiki to catch downloads on AllRecentChanges. For instance the file I refer to is phpmerge.php on the page SimultaneousEdits that has a call to a non-existant function, and by the way, this recipe should be part of the distro as I believe most people don't use a full host with access to all the linux commands, but use more shared hosts I believe. CarlosAB January 13, 2017, at 10:24 PM

OBS: It looks like it can only be used on link and script elements, not sure yet.

I think the UploadQuickReference should be changed to say "Use the top button above to find the "FIle to upload" on your local computer. Currently it says use the "Browse" button, which is what Firefox calls the button, but Safari and Chrome call it a "Choose file" button, and Opera calls it a "Choose…" button. It would be less confusing to users to simply refer to the "top" button. -- RandyB September 18, 2014, at 12:37 AM

Agreed. Also, on a localized browser, the button text is translated into the language of the user. --Petko September 18, 2014, at 03:19 AM

How does the translate work when "Choose file" does not appear to be a string that can be localised?

simon September 18, 2014, at 06:32 PM

The string "Site.UploadQuickReference" can be localized, then another (translated) page will be used. As explained above, the button is labeled differently in different browsers in the same language, so we don't need to insist on the button label. --Petko September 19, 2014, at 01:47 AM

I'd like to include some pages that contain some attachments. But I don't want to have to add {$Group}./ or {$FullName}./ to all Attach links: I'll forget most of them! Any workaround? Tia.

How do I prevent files being uploaded with no extension?

See the Uploads Admin page


Is it possible to create subdirectories for organizing attachments (within the same group)? Specifically, I'm thinking of images... would be very handy....

thanks, Mike

Yes, see the variable $UploadPrefixFmt in UploadsAdmin. --Petko December 28, 2009, at 03:48 AM

Is there a way to hide the "triangle" behind attachment links? Perhaps make it visible to logged in users only? Thanks.

Add to your config.php :

To hide the "triangle"
$LinkUploadCreateFmt = "<a rel='nofollow' class='createlinktext' href='\$LinkUpload'>\$LinkText</a>";

To restore the default behavior to only logged in users (assuming using AuthUser)
if (@$_SESSION['authid']) { $LinkUploadCreateFmt = "<a rel='nofollow' class='createlinktext' href='\$LinkUpload'>\$LinkText</a><a rel='nofollow' class='createlink' href='\$LinkUpload'>&nbsp;&Delta;</a>"; }

Antony Templier October 12, 2011, at 08:19 AM

Thanks, that worked great for hiding the delta! But it is not showing up for logged in users. Could the problem be that I'm using Cookbook.UserAuth2?

John October 12, 2011, at 9:51 AM (EST)

Yes, this tip is for the default authorization system : AuthUser. For UserAuth2, maybe you can try this (but i don't use it, you 'll have to validate yourself) :

To restore the default behavior to only logged in users (assuming using UserAuth2)
if (@$GLOBALS['IsUserLoggedIn']) { $LinkUploadCreateFmt = "<a rel='nofollow' class='createlinktext' href='\$LinkUpload'>\$LinkText</a><a rel='nofollow' class='createlink' href='\$LinkUpload'>&nbsp;&Delta;</a>"; }

Antony Templier October 12, 2011, at 11:36 AM

This didn't work for me to get rid of the triangle, at least not while using (:attachlist {*$Name}:) in a group footer.

What happen when the size of the uploaded file is greater than PHP upload_max_filesize?

Pierre Racine

You will probably see a warning, an error, or a message that PmWiki received no file. --Petko

Is there a way to hide the markup if there is no picture for visitors who are not logged in? Dave Cooke

Answered myself here relatively simple (This is where I'm told no, you only have to do this ...! My answer:

  • In config.php:
$RootUrl = ' domain root url/pmwiki';
$FmtPV['$Headdir'] = "'$RootUrl/uploads/group name '";
  • On page markup
(:if fileexists uploads/group name/{*$Name}.jpg:)
%rfloat width='200px'%{$Headdir}/{*$Name}.jpg%%
(:if1 authid:)%rfloat width='200px'%Attach:{*$Name}.jpg%%(:if1:)

Note *$Name as I placed it in GroupFooter It works

This is a talk page for improving PmWiki.Uploads.