Welcome to Dream.In.Code
Getting Help is Easy!

Join 95,475 Programmers for FREE!. Ask your question and get quick answers from Dream.In.Code experts. There are 954 online right now! We're the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert

Register to Make This Box Go Away!


Form not working?

 
Reply to this topicStart new topic

Form not working?, Coldfusion form not working.

parenteau
post 13 Feb, 2008 - 08:02 PM
Post #1


New D.I.C Head

Group Icon
Joined: 12 Feb, 2008
Posts: 28



Dream Kudos: 50
My Contributions


I don't know why this isn't working...
and cant figure out how to redirect the page.
I am new at this and am really interested in developing what I design... but have run into some language barriers.
here is the code... I feel like I am losing my mind!!! I figured someone could look at this and figure out what I am missing.

CODE

<form action="test.cfm" method="post" enctype="multipart/form-data"><cfif structKeyExists(form, "uploadfile")>
<cfset destination = expandPath("./files")>
<cfif not directoryExists(destination)>
<cfdirectory action="create" directory="#destination#">
</cfif>

<cffile action="upload" filefield="uploadfile" destination="#destination#" nameConflict="makeUnique" result="upload">
<cfdump var="#upload#">
</cfif>
      <div align="center"><table width="500" border="0" align="center" cellpadding="7">
        <tr>
          <td width="100%" bgcolor="#EEF1F7"><p align="center"><b><font face="Tahoma" size="2">Please make sure that the files you are uploading do <br />
            not have the same name as other files you have uploaded!</font></b> </p></td>
        </tr>
        <tr>
          <td width="100%" bgcolor="#E1E6F0"><p align="center"><b><font face="Tahoma" size="2">Upload
            Options</font></b></p></td>
        </tr>
        <tr>
          <td width="100%" bgcolor="#EEF1F7"><table border="0" width="100%" cellpadding="4">
              <tr>
                <td width="34%" align="right" bgcolor="#E1E6F0" valign="top"><font face="Tahoma" size="2"><b>Select
                File To Upload:</b></font></td>
                <td width="66%" bgcolor="#EAEDF4"><p>
                  <input type="file" name="uploadfile" />
                  <br />
                    <br />
                    <input type="submit" value="Upload File" />


--------------------
User is offlineProfile CardPM

Go to the top of the page


sansclue
post 15 Feb, 2008 - 07:36 PM
Post #2


New D.I.C Head

*
Joined: 21 Nov, 2007
Posts: 39



Thanked 1 times
My Contributions


I just noticed the location of your upload tag. Everything else looks good. I think you just need to move your <cffile> upload inside the <cfif> statement. So the code only does the upload after the form is submitted.


CODE

<cfif structKeyExists(form, "uploadfile")>
    <cfset destination = expandPath("./files")>
    <cfif not directoryExists(destination)>
         <cfdirectory action="create" directory="#destination#">
        </cfif>
          
       <cffile action="upload" filefield="uploadfile" destination="#destination#"
           nameConflict="makeUnique" result="upload">
       <cfdump var="#upload#">

</cfif>


The code should work either way, but IMO it's cleaner to place the upload code before the <form> tags, not inside them.

This post has been edited by sansclue: 15 Feb, 2008 - 07:45 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 7/5/08 03:38AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month
-->