6 Replies Latest reply on Jun 12, 2007 6:41 AM by JessiBB

    File Upload Help

    JessiBB
      I'm trying to create a form that will allow my users to submit an article by uploading a word document but when I submit the form it takes me to a page that says that the page I'm trying to reach has errors and can't be displayed. If I refresh the page it looses the information I was trying to pass and just shows me the text of the page without uploading anything. I've tried debugging the pages on my testing server but it can't find any errors and since the error page on my hosted site won't tell me anything specific I'm stuck.

      Here’s the code on my form.

      <form action="article_approve.cfm" method="post" enctype="multipart/form-data" name="submitArticle" id="submitArticle">
      <input name="article" type="file" class="style2" id="article" size="30" maxlength="100" />
      <input name="uploadArticle" type="submit" id="uploadArticle" value="Upload Article" />

      Here’s the code on my approve page.
      <cfif isdefined("form.submitArticle")>
      <cffile action="upload" destination="httpdocs\backend\articles\" filefield="article" nameconflict="makeunique" accept="application/msword" >
      </cfif>

      Thanks in advance!
        • 1. Re: File Upload Help
          chuckbeckwith
          Instead of <cfif isdefined("form.submitArticle")>

          try <cfif len(trim("form.article")) gt 0>
          • 2. Re: File Upload Help
            JessiBB Level 1
            Still not working but this time it did have this at the bottom. (Not that it sheds any light on anything.)

            HTTP 500 - Internal server error
            Internet Explorer
            • 3. Re: File Upload Help
              Level 7
              JessiBB wrote:
              > Still not working but this time it did have this at the bottom. (Not that it sheds any light on anything.)
              >
              > HTTP 500 - Internal server error
              > Internet Explorer

              Your ISP is NOT displaying ColdFusion errors, this is an CF
              Administrator setting. Maybe you can ask them to turn this on to
              provide you more details.

              A quick glance at your code did not show any obvious problems. My first
              guess would be file permission problems. That the location you are
              trying to write the uploaded file is not letting you.

              You might try putting <cftry><cfcatch></cfcatch><cftry> blocks around
              your code and output the error with this so that you don't have to rely
              on the ISP error handling.

              This is a good general practice anyway.
              • 4. Re: File Upload Help
                Level 7
                P.S.

                Basic ISP accounts often disable <cffile ....> functionality. Are you
                sure you are allowed to upload files with your hosting account?
                • 5. Re: File Upload Help
                  iKnowKungFoo Level 1
                  1. The destination attribute requires the full physical path to the upload folder.

                  destination="#expandPath('httpdocs')#\backend\articles\"

                  2. Make sure you have write permission on that folder.

                  3. What Ian said.
                  • 6. Re: File Upload Help
                    JessiBB Level 1
                    Thanks so much everyone.! It works!!!