Advertisement

05.05.2008 at 11:42AM PDT, ID: 23377285
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Not saving image upload information to database

Tags: coldfusion 8, mozilla, localhost
What I'm trying to do with this code is upload an image to a temp folder and resize it.  Then after that I want to copy the image to a different folder and rename it to logo.jpg.  The code does work accept when I try to save it to the database.  I'm not getting an errors at all.  I attach the code below.

The reason I want to copy it is because the file becomes locked when I resize the image or if it was viewed.  It takes about 2 minutes for the server to unlock the image.  I was reading online that this was a workaround for the problem.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
<CFIF isDefined("Form.isLogo")>  
<cfif isdefined("form.upload_now")>
<!--- Get photo count to see if we are already at our limit --->
<cfquery name="getphotos" datasource="security">
  SELECT Count(logoID) AS PhotoCount
  FROM logo
  WHERE memberID = #memberID#
</cfquery>
<cfset destination="c:\coldfusion8\wwwroot\myMobi\photos\m"&#memberID#&"\logo\" >
<cfset destinationtemp="c:\coldfusion8\wwwroot\myMobi\photos\temp\">
<cfif Not DirectoryExists(destination) >
<cfdirectory action="create" directory="#destination#" >
</cfif>
<!--- Check limit --->
<cfif getphotos.PhotoCount GTE 1>
  <span class="style2">Only 1 photo can be uploaded to the system. Delete your logo to uploaded a different one.
  <cfelse>
  <!--- Upload file --->
  <cffile action="upload" filefield="ul_path" destination="#destinationtemp#" accept="image/jpg, image/jpeg, image/pjpeg, pjpg" nameConflict= "MakeUnique">
  <cfimage action="resize" source="#destinationtemp##serverfile#" width="150" Height="150" destination="#destinationtemp##serverfile#" overwrite="true" />
  <cffile action="copy" source="#destinationtemp##serverfile#" destination="#destination#logo.jpg">
  <cfset clientFile = #cffile.clientFile#>
  <cfoutput>File uploaded succesfully #destination##serverFile#</cfoutput>
  
  <!--- Check filetype --->
  <cfif cffile.ClientFileExt NEQ "jpg" AND cffile.ClientFileExt NEQ "jpeg">
    File is wrong type. You can only upload JPG file types.
    <cffile action="delete" file="#destination#">
  </cfif>
  <!--- Make sure file upload was success, then create database record --->
        <cfif FileExists("#destination##cffile.serverFile#")>
    <cftry>
      <cfquery name="createPhotoRecord" datasource="security">
      INSERT INTO logo(memberid,location,filename)
      VALUES(<cfqueryparam cfsqltype="CF_SQL_BIGINT" value="#memberid#">,
             <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#destination#">,
             <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#clientFile#">)
      </cfquery>
          <cfcatch>
            <br>
            -->File replaced.<br> 
          </cfcatch>
    </cftry>
          <cfelse> 
              </cfif>
  </span>
</cfif>
</cfif>
Start your free trial to view this solution
Question Stats
Zone: Web Development
Question Asked By: sonicimpulse
Solution Provided By: gdemaria
Participating Experts: 1
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
05.05.2008 at 07:07PM PDT, ID: 21504313

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628