[pmwiki-users] Extracting the uploadfile name

The Editor editor at fast.st
Mon Apr 2 13:13:57 CDT 2007


On 4/2/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Mon, Mar 26, 2007 at 07:39:53PM +0200, Benoit Dutilleul wrote:
> >    I got no answer so I publish this one again. I hope you can provide me an
> >    answer!
> >    2007/3/24, Benoit Dutilleul < benoit.dutilleul at googlemail.com>:
> >
> >      Dear all,
> >
> >      I'm working on a ZAP module to enable members of my pmwiki site to
> >      upload a picture associated to their profile. In order to keep the
> >      script and further operations as simple as possible, I would like to
> >      save the file with the following format:
> >      {$AuthId}_uploadfile
> >
> >      The current version of my script is:
> >      > (:zapform upload key=UploadPhoto:)
> >      > File: (:input file uploadfile:)
> >      > (:input hidden upname value="{$AuthId}_{uploadfile}":)
> >      > (:zap upload="" UploadPhoto:)
> >      > (:input submit value="Upload" UploadPhoto:)
> >      > (:zapend:)
> >      However, this does not work because upname is only {$AuthId}_.
> >      Dan told me that this may be because "the uploadfile field probably does
> >      not
> >      contain a file name, it actually contains a file".
> >
> >      Do you know how I can extract the original file name?
>
> I don't know how to make it work with ZAP, but the original file name
> (the one that appears in the browser's upload box) is available in the PHP
> variable  $_FILES['uploadfile']['name'] .
>
> Of course, this means that ZAP would have adjust "upname" for the filename
> at the time the file is uploaded -- PmWiki can't substitute it directly
> as part of the form markup (because PmWiki doesn't know the name until
> after the form is submitted).
>
> Hope this helps,


Looks helpful.  I'm basically using a slightly hacked version of the
upload function you use Pm, with the ability to change the redirect
page.  I'm assuming I could reset the upname function after the file
has uploaded (form has been submitted, ZAP is called), and before the
upload function you wrote executes.  Is that correct?

I could do the same for retrieving type, and size, say perhaps to use
conditionals to further limit how zap uploads work, right in the form
itself.  Cool.

Cheers,
Dan



More information about the pmwiki-users mailing list