• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Error uploading images and trying to update Access

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
gregoryrsmith
Asked:
gregoryrsmith
  • 3
  • 2
  • 2
2 Solutions
 
mrichmonCommented:
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
 
gregoryrsmithAuthor Commented:
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
 
mrichmonCommented:
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
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
gregoryrsmithAuthor Commented:
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
 
mrichmonCommented:
Instead of
<cfset picName = "form.pic" & #i#>
<cfset folderName = "form.folder" & #i#>

try

<cfset pcName = Form["pic" & i]>
<cfset folderName = Form["folder" & i]>
0
 
Tacobell777Commented:
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
 
Tacobell777Commented:
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now