|
Cookbook /
MultiUploadSummary: Upload multiple files at once by packing them in a zip archive & extracting them on the server
Version: 2007-11-27
Prerequisites: PmWiki 2.2.0-beta series, untested on 2.1.27 and earlier. Also requires PHP 5 ZipArchive support.
Status: beta
Maintainer: EemeliAro
Categories: Uploads
Discussion: MultiUpload-Talk
Questions answered by this recipe
DescriptionMultiUpload adds an option to the upload page to "Extract archive contents". If the uploaded file is a valid (zip) archive, this will extract the files from the archive and add them to the current page as if they were individually uploaded. To install this recipe
include_once("$FarmD/cookbook/multiupload.php");
NotesMultiUpload requires PHP 5 ZipArchive support and will abort if that isn't available. Verification of uploaded files when using MultiUpload is not done using the function defined in You may want to check your Since this modifies the upload form, you may be interested to add the following (or something similar) to your Site.UploadQuickReference page: To upload multiple files at once, put them in a zip archive and check the "Extract archive contents" box before uploading it. This will extract the files on the server as if they were individually uploaded.
How it worksWhen a file is uploaded with MultiUpload will stop at the first error, but won't undo any changes made before then, ie. an error on the fifth file in an archive will still result in four saved files. Alternative form layoutThe default layout set by MultiUpload is very similar to the default upload form layout. Here's an alternative form layout (the one I actually use) that you can add to you configuration file. It has wider edit fields and tooltip explanations. It's rather hard to get the layout to work decently due to the different file input implementations in different browsers. $PageUploadFmt = array("<h2>Attachments for {\$Group} group</h2>
<h3 class='wikimessage'>\$UploadResult</h3>
<div id='wikiupload' class='wikibox' style='margin:0 40px;padding:20px;'>
<form enctype='multipart/form-data' action='{\$PageUrl}' method='post'>
<input type='hidden' name='n' value='{\$FullName}' />
<input type='hidden' name='action' value='postmultiupload' />
<table border='0' style='margin:0 auto;'><tr>
<td align='right'><acronym title='Browse to the file on your computer that
you want to upload.'>File to upload</acronym> </td>
<td><input name='uploadfile' type='file' size='30' /></td>
</tr><tr>
<td align='right'><acronym title='Optional, default is the uploaded
filename. Filename requires extension.'>Name on server</acronym> </td>
<td><input type='text' name='upname' value='\$UploadName' size='30' /></td>
</tr><tr>
<td colspan='2' align='right'><label><acronym title='Check to upload
multiple files inside a zip file.'>Extract archive contents</acronym>
<input type='checkbox' name='extract' id='extract' /></label>
<input type='submit' value='Upload' style='margin-left:5em;' /></td>
</tr></table></form></div>",
'wiki:$[{$SiteGroup}/UploadQuickReference]');
Also note that this variable is set in MultiUpload using SDV, so including the script file upload.php before including multiupload.php requires you to define your own $PageUploadFmt. Release Notes
See Also
ContributorsCommentsSee discussion at MultiUpload-Talk
I put this together in less than a day, so be aware that it may fail in odd ways. The ZipArchive requirement is due to that being available on the server I use and its interface looking relatively simple. I'm actually not sure what filetypes it'll accept, the only one I've bothered to check so far is Hi. Can you upload some pmwiki page code that makes this work? Also - anyone foresee a way to make this work with PHP v.4.4.8 (ZLib 1.2.1.2)? overtones99 February 27, 2008, at 12:50 AM User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |