Solved

Error uploading images and trying to update Access

Posted on 2004-10-31
162 Views
Last Modified: 2013-12-24
Hi,

I'm trying to build a back end to a photo gallery where I can upload images and update my dayabase to reflect the new titles. I think I've painted myself into a corner and am stuck, could use some help. Thank You.

The first page uploads the titles and works.

<cfquery name="getNewName" datasource="shalmy2">
SELECT *
FROM titles
WHERE num = #FORM.selectNumber#
</cfquery>

<cfoutput query="getNewName">
  <cfform action="scenes22.cfm" method="post" name="form1" enablecab="yes">
    <input name="number" type="hidden" value="#num#">
    <input name="newTitle" type="text" value="#title#" size="50" required="no">
    <br>
      <textarea name="newComments" rows="3" cols="80">#comments#</textarea>
    <br>
    <div align="center">
      <input name="submit" type="submit" value="Update Title">
    </div>
  </cfform>
</cfoutput>

This page updates the title and comments, deletes the previous image names and gets a form ready for uploading the actual photos

<cfquery datasource="shalmy2">
UPDATE titles
SET title = '#FORM.newTitle#',
    comments = '#FORM.newComments#'
WHERE num = #FORM.number#
</cfquery>

<cfquery datasource="shalmy2">
UPDATE imageNames
SET imageName = NULL
WHERE folderNum = #FORM.number#
</cfquery>

<cfquery name="uploadThumbs" datasource="shalmy2">
SELECT *
FROM imageNames
WHERE folderNum = #FORM.number#
</cfquery>

   <form action="scenes25.cfm" enctype="multipart/form-data" method="post">

            <cfoutput query="uploadThumbs">      
      <input name="folder#num#" type="hidden" value="#newFolderNum#">      
      <input name="pic#num#" type="file" size="25">
             </cfoutput>

            
  <div align="center">
    <input type="Submit" name="upload" value="upload">
  </div>
</form>

Here's where I have the trouble. This page is supposed to load the photos and update Access. I don't know if the action page will even upload the photos, CF won't let me get past the WHERE clause in the query.

<cfloop FROM= "1" TO= "10" index="i">
<cfset picName = "form.pic" & #i#>
<cfset folderName = "form.folder" & #i#>
<cfquery name="#i#" datasource="shalmy2">
UPDATE imageNames
SET imageName = '#picName#'
WHERE folderNum = '#folderName#' AND num = #i#
</cfquery>
</cfloop>



    <cfloop index="i" from="1" to="10" step="1">
      <cfset filename = "form.pic" & #i#>
      <cfif evaluate(variables.filename) neq "">

        <cffile action="UPLOAD"
                 destination="C:\CFusionMX\wwwroot\experiments\thumbs\"
           nameconflict="OVERWRITE"
           filefield="#variables.filename#">

        <cfset message = message & ",File%20#i#%20(#file.serverfile#)%20was%20uploaded">
      <cfelse>
        <cfset message = message & ",File%20#i#%20was%20empty">
      </cfif>
    </cfloop>

Thanks,
Greg Smith

0
Question by:gregoryrsmith
    7 Comments
     
    LVL 35

    Expert Comment

    by:mrichmon
    Personally I would NOT upload the images into Access.  You will end up with a very very very slow website and a huge databse.

    What I would do is upload the files to a directory on your webserver and then store the path in the access database as a text field.

    Then you simply display by:

    <img src="#imagePath#">
    0
     

    Author Comment

    by:gregoryrsmith
    The question was poorly titled.

    I'm trying to upload photos to the server using cffile and at the same time,  I'm trying to update image names into Access

    Evereything works well until the last page CF has a problem wiht the WHERE clause
    0
     
    LVL 35

    Expert Comment

    by:mrichmon
    What is the error?

    UPDATE imageNames
    SET imageName = '#picName#'
    WHERE folderNum = '#folderName#' AND num = #i#

    does not seem to have a problem unless the fact that folderNum is a number and '#folderName#' is a string?
    0
     

    Author Comment

    by:gregoryrsmith
    Now the last page gives me HTTP error 500, and tthis is loaded into the database where the image name should be C:\CFusionMX\runtime\servers\default\SERVER-INF\te
    0
     
    LVL 35

    Assisted Solution

    by:mrichmon
    Instead of
    <cfset picName = "form.pic" & #i#>
    <cfset folderName = "form.folder" & #i#>

    try

    <cfset pcName = Form["pic" & i]>
    <cfset folderName = Form["folder" & i]>
    0
     
    LVL 17

    Expert Comment

    by:Tacobell777
    what is the size of the field in the database? Maybe its to small and cuts of the path? C:\CFusionMX\runtime\servers\default\SERVER-INF\te


    Also, go into your browser, tools, internet options, advanced, untick "show friendly error messages"
    then visit your page again and paste error here.
    0
     
    LVL 17

    Accepted Solution

    by:
    also

    <cffile action="UPLOAD"
                   destination="C:\CFusionMX\wwwroot\experiments\thumbs\"
               nameconflict="OVERWRITE"
               filefield="#variables.filename#">

    Should be

    <cffile action="UPLOAD"
                   destination="C:\CFusionMX\wwwroot\experiments\thumbs\"
               nameconflict="OVERWRITE"
               filefield="filename">

    just the name of the form field
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
    This video discusses moving either the default database or any database to a new volume.

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now