Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ok - what am I doing wrong? I am b

Status
Not open for further replies.

CTekMedia

Programmer
Oct 5, 2001
634
US
Ok - what am I doing wrong? I am building an intranet and want users to be able to upload graphics. Everything works fine and the file is uploaded with the correct name to the correct folder. However, the file name (CFFILE.SERVERFILE)is being changed (e.g., C:\WINNT\TEMP\ACF165.tmp) when I try to write it to my database field (photo).

I know I need to make a connection between cffile.serverfile and PHOTO. I'm stumped as to how. Nothing seems to work.

Thanks!

<cfinclude template=&quot;../../Connections/Excess.cfm&quot;>
<cfparam name=&quot;ID&quot; default=&quot;1&quot;>
<cfparam name=&quot;Recordset1__varID&quot; default=&quot;#ID#&quot;>
<cfquery name=&quot;Recordset1&quot; datasource=#MM_Excess_DSN# username=#MM_Excess_USERNAME# password=#MM_Excess_PASSWORD#>
SELECT ID FROM tb_main WHERE ID LIKE '#Recordset1__varID#'
</cfquery>

<html>
<head>
<title>Insite</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<link rel=&quot;stylesheet&quot; href=&quot;../../in2.css&quot; type=&quot;text/css&quot;>

</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot; link=&quot;#000099&quot; vlink=&quot;#000099&quot; alink=&quot;#000099&quot;>

<CFFILE action=&quot;upload&quot;
filefield=&quot;photo&quot;
nameconflict=&quot;overwrite&quot;
destination=&quot;C:\Inetpub\

<CFUPDATE DATASOURCE=&quot;#MM_Excess_DSN#&quot;
TABLENAME=&quot;tb_main&quot;
FORMFIELDS=&quot;photo&quot;>

<div id=&quot;Layer1&quot; style=&quot;position:absolute; left:37px; top:21px; width:477px; height:257px; z-index:1&quot;>You
have uploaded
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td>ID</td>
<td><cfoutput>#Recordset1.ID#</cfoutput></td>
</tr>
<tr>
<td>Attempted Server File</td>
<td><cfoutput>#cffile.AttemptedServerFile#</cfoutput></td>
</tr>
<tr>
<td>Client Directory</td>
<td><cfoutput>#cffile.ClientDirectory#</cfoutput></td>
</tr>
<tr>
<td>Client File Name</td>
<td><cfoutput>#cffile.ClientFileName#</cfoutput></td>
</tr>
<tr>
<td>Client File Extension</td>
<td><cfoutput>#cffile.ClientFileExt#</cfoutput></td>
</tr>
<tr>
<td>Content Sub Type</td>
<td><cfoutput>#cffile.ContentSubType#</cfoutput></td>
</tr>
<tr>
<td>Date Last Accessed</td>
<td><cfoutput>#cffile.DateLastAccessed#</cfoutput></td>
</tr>
<tr>
<td>File Existed</td>
<td><cfoutput>#cffile.FileExisted#</cfoutput></td>
</tr>
<tr>
<td>File Size</td>
<td><cfoutput>#cffile.FileSize#</cfoutput></td>
</tr>
<tr>
<td>File Was Appended</td>
<td><cfoutput>#cffile.FileWasAppended#</cfoutput></td>
</tr>
<tr>
<td>File Was Overwritten</td>
<td><cfoutput>#cffile.FileWasOverwritten#</cfoutput></td>
</tr>
<tr>
<td>File Was Renamed</td>
<td><cfoutput>#cffile.FileWasRenamed#</cfoutput></td>
</tr>
<tr>
<td>File Was Saved</td>
<td><cfoutput>#cffile.FileWasSaved#</cfoutput></td>
</tr>
<tr>
<td>Old File Size</td>
<td><cfoutput>#cffile.OldFileSize#</cfoutput></td>
</tr>
<tr>
<td>Server Directory</td>
<td><cfoutput>#cffile.ServerDirectory#</cfoutput></td>
</tr>
<tr>
<td>Server File</td>
<td><cfoutput>#cffile.ServerFile#</cfoutput></td>
</tr>
<tr>
<td>Server File Ext</td>
<td><cfoutput>#cffile.ServerFileExt#</cfoutput></td>
</tr>
<tr>
<td>Time Created</td>
<td><cfoutput>#cffile.TimeCreated#</cfoutput></td>
</tr>
<tr>
<td>Time Last Modified</td>
<td><cfoutput>#cffile.TimeLastModified#</cfoutput></td>
</tr>
</table>
</div>




</body>
</html> Peace
BT
 
I had similar problems I also needed to place the file in a different llcation. Hope this helps

<cfoutput>

<CFSCRIPT>

thisPath = ExpandPath(&quot;*.*&quot;);
imgDirectory1 = GetDirectoryFromPath(thisPath);
// get the above directory 2 levels down &quot;../../&quot;
imgDirectory2 = ListDeleteAt(imgDirectory1, ListLen(imgDirectory1, &quot;\&quot;),&quot;\&quot;);
imgDirectory2 = ListDeleteAt(imgDirectory2, ListLen(imgDirectory2, &quot;\&quot;),&quot;\&quot;) & &quot;\shopping_center&quot;;


</CFSCRIPT>

<CFSET thisPath= ExpandPath(&quot;*.*&quot;)>
<CFSET imgDirectory= GetDirectoryFromPath(thisPath)>

<CFIF IsDefined(&quot;FORM.p_picture&quot;) AND FORM.p_picture NEQ &quot;&quot;>
<CFTRY>
<!--- Upoad File --->
<CFFILE ACTION=&quot;UPLOAD&quot;
FILEFIELD=&quot;FORM.p_picture&quot;
DESTINATION=&quot;#VARIABLES.imgDirectory1#&quot;
NAMECONFLICT=&quot;Overwrite&quot;>

<!--- Rename Img --->
<CFFILE ACTION=&quot;RENAME&quot;
SOURCE=&quot;#VARIABLES.imgDirectory1#\#CFFILE.ServerFile#&quot;
DESTINATION=&quot;#VARIABLES.imgDirectory2#\pictures\pic#p_id#.#CFFILE.ServerFileExt#&quot;>
<cfset picture=&quot;pic#p_id#.#CFFILE.ServerFileExt#&quot;>
<!--- Catch error, if it's not a jpg or gif file --->
<CFCATCH TYPE=&quot;Any&quot;>
I'm sorry, you must upload a .gif or .jpg file.
</CFCATCH>
</CFTRY>

</CFIF>

</cfoutput>


<cfoutput>

<cfquery datasource=#datasource# username=#username# password=#password#>
update table set
p_picture='#picture#'
where p_id=#p_id#
</cfquery>

</cfoutput>
 
Thanks much Izacher. It ran into the wall a few more times and came up with this - which works. I need to add error trapping and lock out the DB. I'm posting this in case it helps someone down the line. It only took me 20+ hours lol.

<cfinclude template=&quot;../../Connections/Excess.cfm&quot;>
<cfscript>
// *** Edit Operations: declare variables

// set the form action variable
MM_editAction = CGI.SCRIPT_NAME;
If (CGI.QUERY_STRING NEQ &quot;&quot;) {
MM_editAction = MM_editAction & &quot;?&quot; & CGI.QUERY_STRING;
}

// boolean to abort record edit
MM_abortEdit = false;

// query string to execute
MM_editQuery = &quot;&quot;;
</cfscript>
<cfscript>
// *** Update Record: set variables

If (IsDefined(&quot;MM_update&quot;) AND IsDefined(&quot;MM_recordId&quot;)) {

MM_editDatasource = #MM_Excess_DSN#;
MM_editUserName = #MM_Excess_USERNAME#;
MM_editPassword = #MM_Excess_PASSWORD#;
MM_editTable = &quot;tb_main&quot;;
MM_editColumn = &quot;ID&quot;;
MM_recordId = &quot;&quot; & MM_recordId & &quot;&quot;;
MM_editRedirectUrl = &quot;ack_update.htm&quot;;
MM_fieldsStr = &quot;photo|value&quot;;
MM_columnsStr = &quot;photo|',none,''&quot;;

// create the MM_fields and MM_columns arrays
MM_fields = ListToArray(MM_fieldsStr,&quot;|&quot;);
MM_columns = ListToArray(MM_columnsStr,&quot;|&quot;);

// set the form values
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
MM_fields[i+1] = IIf(IsDefined(MM_fields),&quot;FORM.&quot; & MM_fields,DE(&quot;&quot;));
}

// append the query string to the redirect URL
If (MM_editRedirectUrl NEQ &quot;&quot; AND CGI.QUERY_STRING NEQ &quot;&quot;) {
If (Find(&quot;?&quot;, MM_editRedirectUrl) EQ 0) {
MM_editRedirectUrl = MM_editRedirectUrl & &quot;?&quot; & CGI.QUERY_STRING;
} Else {
MM_editRedirectUrl = MM_editRedirectUrl & &quot;&&quot; & CGI.QUERY_STRING;
}
}
}
</cfscript>
<cfscript>
// *** Update Record: construct a sql update statement and execute it

If (IsDefined(&quot;MM_update&quot;) AND IsDefined(&quot;MM_recordId&quot;)) {

// create the update sql statement
MM_editQuery = &quot;update &quot; & MM_editTable & &quot; set &quot;;
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
FormVal = MM_fields[i+1];
MM_typesArray = ListToArray(MM_columns[i+1],&quot;,&quot;);
Delim = IIf(MM_typesArray[1] NEQ &quot;none&quot;,&quot;MM_typesArray[1]&quot;,DE(&quot;&quot;));
AltVal = IIf(MM_typesArray[2] NEQ &quot;none&quot;,&quot;MM_typesArray[2]&quot;,DE(&quot;&quot;));
EmptyVal = IIf(MM_typesArray[3] NEQ &quot;none&quot;,&quot;MM_typesArray[3]&quot;,DE(&quot;&quot;));
If (FormVal EQ &quot;&quot;) {
FormVal = EmptyVal;
} Else {
If (AltVal NEQ &quot;&quot;) {
FormVal = AltVal;
} Else If (Delim EQ &quot;'&quot;) { // escape quotes
FormVal = &quot;'&quot; & Replace(FormVal,&quot;'&quot;,&quot;''&quot;,&quot;ALL&quot;) & &quot;'&quot;;
} Else {
FormVal = Delim & FormVal & Delim;
}
}
If (i GT 1) MM_editQuery = MM_editQuery & &quot;,&quot;;
MM_editQuery = MM_editQuery & MM_columns & &quot; = &quot; & FormVal;
}
MM_editQuery = MM_editQuery & &quot; where &quot; & MM_editColumn & &quot; = &quot; & MM_recordId;
}
</cfscript>
<cfif Not #MM_abortEdit# AND IsDefined(&quot;MM_update&quot;) AND IsDefined(&quot;MM_recordId&quot;)>
<cfquery name=&quot;MM_editCmd&quot; datasource=#MM_editDatasource# username=#MM_editUserName# password=#MM_editPassword#>
#PreserveSingleQuotes(MM_editQuery)#
</cfquery>
<cfif #MM_editRedirectUrl# NEQ &quot;&quot;>
<cflocation url=&quot;#MM_editRedirectUrl#&quot; addtoken=&quot;no&quot;>
</cfif>
</cfif>
<cfparam name=&quot;ID&quot; default=&quot;1&quot;>
<cfparam name=&quot;Recordset1__varID&quot; default=&quot;#ID#&quot;>
<cfquery name=&quot;Recordset1&quot; datasource=#MM_Excess_DSN# username=#MM_Excess_USERNAME# password=#MM_Excess_PASSWORD#>
SELECT ID, name, category, location FROM tb_main WHERE ID LIKE '#Recordset1__varID#'
</cfquery>

<html>
<head>
<title>Insite</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<link rel=&quot;stylesheet&quot; href=&quot;../../in2.css&quot; type=&quot;text/css&quot;>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(&quot;?&quot;))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
//-->
</script>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot; link=&quot;#000099&quot; vlink=&quot;#000099&quot; alink=&quot;#000099&quot;>

<div id=&quot;main&quot; style=&quot;position:absolute; left:162px; top:8px; width:376px; height:254px; z-index:2; background-color: #CC9999; layer-background-color: #CC9999; border: 1px none #000000;&quot;>
<form name=&quot;form1&quot; method=&quot;POST&quot; action=&quot;<cfoutput>#MM_editAction#</cfoutput>&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
</tr>
<tr>
<td> <div align=&quot;center&quot; class=&quot;menuinfocellCopy&quot;>Please Verify Data And
Then Submit</div></td>
</tr>
</table>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td class=&quot;menuinfocellCopy&quot;><img src=&quot;../../Images/shim20by12.gif&quot; width=&quot;20&quot; height=&quot;12&quot;></td>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>ID</td>
<td class=&quot;menuinfocellCopy&quot;><cfoutput>#Recordset1.ID#</cfoutput> </td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>Name</td>
<td class=&quot;menuinfocellCopy&quot;><cfoutput>#Recordset1.name#</cfoutput></td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>Category</td>
<td class=&quot;menuinfocellCopy&quot;><cfoutput>#Recordset1.category#</cfoutput></td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>Location</td>
<td class=&quot;menuinfocellCopy&quot;><cfoutput>#Recordset1.location#</cfoutput></td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>Photo Name</td>
<CFFILE action=&quot;upload&quot;
filefield=&quot;photo&quot;
nameconflict=&quot;overwrite&quot;
destination=&quot;C:\Inetpub\ <td class=&quot;menuinfocellCopy&quot;> <input name=&quot;photo&quot; type=&quot;text&quot; id=&quot;photo&quot; value=&quot;<cfoutput>#cffile.ServerFile#</cfoutput>&quot;>
</td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;> <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;></td>
</tr>
<tr>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
<td class=&quot;menuinfocellCopy&quot;>&nbsp;</td>
</tr>
</table>
<span class=&quot;menuinfocell&quot;>
<input type=&quot;hidden&quot; name=&quot;MM_update&quot; value=&quot;true&quot;>
<input type=&quot;hidden&quot; name=&quot;MM_recordId&quot; value=&quot;<cfoutput>#Recordset1.ID#</cfoutput>&quot;>
</span>
</form>
<p class=&quot;menuinfocell&quot;><a href=&quot;javascript:;&quot; class=&quot;menuinfocell&quot; onClick=&quot;MM_showHideLayers('details','','show')&quot;>Show
Technical Details</a></p>
</div>





<div id=&quot;details&quot; style=&quot;position:absolute; left:172px; top:276px; width:477px; height:257px; z-index:1; visibility: hidden;&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td>Attempted Server File</td>
<td><cfoutput>#cffile.AttemptedServerFile#</cfoutput></td>
</tr>
<tr>
<td>Client Directory</td>
<td><cfoutput>#cffile.ClientDirectory#</cfoutput></td>
</tr>
<tr>
<td>Client File Name</td>
<td><cfoutput>#cffile.ClientFileName#</cfoutput></td>
</tr>
<tr>
<td>Client File Extension</td>
<td><cfoutput>#cffile.ClientFileExt#</cfoutput></td>
</tr>
<tr>
<td>Content Sub Type</td>
<td><cfoutput>#cffile.ContentSubType#</cfoutput></td>
</tr>
<tr>
<td>Date Last Accessed</td>
<td><cfoutput>#cffile.DateLastAccessed#</cfoutput></td>
</tr>
<tr>
<td>File Existed</td>
<td><cfoutput>#cffile.FileExisted#</cfoutput></td>
</tr>
<tr>
<td>File Size</td>
<td><cfoutput>#cffile.FileSize#</cfoutput></td>
</tr>
<tr>
<td>File Was Appended</td>
<td><cfoutput>#cffile.FileWasAppended#</cfoutput></td>
</tr>
<tr>
<td>File Was Overwritten</td>
<td><cfoutput>#cffile.FileWasOverwritten#</cfoutput></td>
</tr>
<tr>
<td>File Was Renamed</td>
<td><cfoutput>#cffile.FileWasRenamed#</cfoutput></td>
</tr>
<tr>
<td>File Was Saved</td>
<td><cfoutput>#cffile.FileWasSaved#</cfoutput></td>
</tr>
<tr>
<td>Old File Size</td>
<td><cfoutput>#cffile.OldFileSize#</cfoutput></td>
</tr>
<tr>
<td>Server File</td>
<td><cfoutput>#cffile.ServerFile#</cfoutput></td>
</tr>
<tr>
<td>Server File Ext</td>
<td><cfoutput>#cffile.ServerFileExt#</cfoutput></td>
</tr>
<tr>
<td>Time Created</td>
<td><cfoutput>#cffile.TimeCreated#</cfoutput></td>
</tr>
<tr>
<td>Time Last Modified</td>
<td><cfoutput>#cffile.TimeLastModified#</cfoutput></td>
</tr>
</table>
</div>




</body>
</html> Peace
BT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top