Skip to main content
Known Participant
January 11, 2007
Question

Passing hidden input type file through pages

  • January 11, 2007
  • 3 replies
  • 450 views
I have a form where there is a form field type file. If I browse and pick the file and post it to next page I m not able to retrieve it as hidden type in form. I try to post that form againa and the error I m getting is " The form field "logo" did not contain a file.".

The way I m trying to get the file field is like this:
<cfif #form.logo# neq ''>
<input type="hidden" name="logo" value="#form.logo#" />
</cfif>

where form.logo is <input type="file" name="logo" /> in the page where it is posted from.

Now I want to post the form to another page keeping that logo file and upload it to folder and putting the path in database using:
<cfif isdefined("form.logo")>
<cffile ACTION="UPLOAD" FILEFIELD="logo" DESTINATION="W:\BCHRMA\bchrma-site\content\postjobs\uploadedlogo\" nameconflict="overwrite">

This gives an error "The form field "logo" did not contain a file.". Please help if anyone has a solution around it.

Thankyou
    This topic has been closed for replies.

    3 replies

    mvierow
    Inspiring
    January 12, 2007
    Assuming you can't simply move the file field to the second page, you'll need to process your cffile tag before proceding to the second page, then use CFFILE.ServerFile as the value of your hidden field.
    Participating Frequently
    January 11, 2007
    looks like a network error caused a double post. duplicate content removed.
    Participating Frequently
    January 11, 2007
    ColdFusion doesn't (HTML for that matter either) can't fill a value for form field of type file on a users browser, not only would that be a huge bandwidth issue, imagine if the user uploaded a 10 meg file, there would also be some significant security issues if you could.

    So, since it sounds like you're using a multiple forms for the submission, I'd suggest creating a temporary directory to store the uploaded file(s), assign the folder name as a UUID and either store it in a session variable, where all you'll have to do is check that the session hasn't expired and retrieve the value for processing the file, or pass back the UUID as the hidden form element.

    You'll need some sort of routine for cleaning up the temporary files should the user happen to abandon the final form submission, which could be handled using a timestamp of the folder datelastmodified of a cfdirectory query if it was older than x days, etc.