Forums

how to recover the file name from file upload in CF

ajw3208 13 Oct, 2009
Hi guys,

How do I recover the filename entered in the file upload mechanism in CF?

I know where you set the directory for the file to be stored and where you set the naming convention that determines the uploaded file's final name, what I can't work out is how to recover the resulting file name so I can use it to help define a <img> html tag.

Can you help?

Thanks

aj
GreyHead 13 Oct, 2009
Hi aj,

It's in the $attachments array - possibly $MyForm->attachments

Bob
ajw3208 20 Oct, 2009
Hi Bob,

I turned debug and got the following. The information I need is contained in item 8. I can see the name in the $_files array ([name]) but there is no reference as to what I need to "grab" to get the info in item 8.

Thoughts? (a code snippet would be helpful if possible) :wink:

Many thanks

aj

   1. Form passed first SPAM check OK
   2. Form passed the submissions limit (if enabled) OK
   3. Form passed the Image verification (if enabled) OK
   4. Form passed the server side validation (if enabled) OK
   5. $_POST Array: Array ( [wphcfcTeam] => anthony [oppositionTeam] => watts [matchDate] => 01/10/2009 [wphcfcScore] => 5 [oppositionScore] => 1 [matchReport] => gfdsgfsdfgs [attitude] => N/A [skill] => N/A [participation] => N/A [sportmanship] => N/A [name] => ajw [emailAddress] => fred@domain.com [text_20] => hgfd [button_20] => Submit [e786df0726814c05bc139655e64390ad] => 1 [1cf1] => 280c622b0e668c04eaedb77647ad757f [chronoformname] => match_report_form )
   6. $_FILES Array: Array ( [matchPhoto] => Array ( [name] => SoccerBallSmall.jpg [type] => image/jpeg [tmp_name] => /tmp/phpQ1rfGr [error] => 0 [size] => 957 ) )
   7. Upload routine started for file upload by : matchPhoto
   8. /home/wphcfc/public_html/components/com_chronocontact/uploads/match_report_form/20091020061219_SoccerBallSmall.jpg has been uploaded OK
   9. Form passed the plugins step (if enabled) OK
  10. An email has been SENT successfully from (match report system)freed@domain.com to fred@domain.com
  11. An email has been SENT successfully from (headlions Newsletter Editor)newsletterfred@domain.com to fred@domain.com
  12. An email has been SENT successfully from (match report system)adminfred@domain.com to fred@domain.com
  13. Debug End
GreyHead 20 Oct, 2009
Hi aj,

It still in the $attachments array - possibly $MyForm->attachments

The $_FILES array shows you the name of the uploaded file but ChronoForms changes that by default so it's not too useful.

Bob
This topic is locked and no more replies can be posted.