lulu50
asked on
File upload
Hi,
I am using on my application a file upload to let the user upload images or any type of files.
My question is with the code I posted below, can I upload an email file?
Please, tell me why I can upload any other type of file but not an email file?
Can coldfusion, upload an email file?
Thanks,
Lulu
I am using on my application a file upload to let the user upload images or any type of files.
My question is with the code I posted below, can I upload an email file?
Please, tell me why I can upload any other type of file but not an email file?
Can coldfusion, upload an email file?
Thanks,
Lulu
<cfsetting showdebugoutput="yes">
<cfset filelocation = expandpath('uploadedfiles/')>
<cfset maxFiles = 3>
<cfset x=0>
<cfset cnt=0>
<cfset Attachments="">
<cfloop from="1" to="#variables.maxFiles#" index="ii">
<cftry>
<cfif StructKeyExists(form,"AttachFile" & ii) && len(trim(Form["AttachFile" & ii]))>
<CFFILE ACTION="UPLOAD"
FILEFIELD="AttachFile#ii#"
DESTINATION="#variables.filelocation#"
NAMECONFLICT="makeunique">
<cfset Attachments=ListAppend(variables.Attachments,cffile.serverfile)>
</cfif>
<cfif StructKeyExists(form,"FileID" & ii) && len(trim(Form["FileID" & ii]))>
<cfset variables["FileID" & ii] = Form["FileID" & ii]>
</cfif>
<cfif StructKeyExists(form,"FileDescription" & ii) && len(trim(Form["FileDescription" & ii]))>
<cfset variables["Descp" & ii] = Form["FileDescription" & ii]>
</cfif>
<cfcatch>
<br>#cfcatch.message#<br>#cfcatch.detail#<br>
#cfcatch.tagContext[1].template# Line #cfcatch.tagContext[1].line#
</cfcatch></cftry>
</cfloop>
<cfloop from="1" to="#variables.maxFiles#" index="ii">
<cfif (StructKeyExists(form,"FileID" & ii) && len(trim(Form["FileID" & ii]))) && #Form["FileID" & ii]# neq "">
<cfset x++/>
<cfquery name = "QGetFileName" datasource="#strDSN#" username="#strUID#" password="#strPWD#">
select UploadedFile from Files
where FileID = #variables["FileID" & ii]#
</cfquery>
<cfset convertfile = #tostring(tobinary(QGetFileName.UploadedFile))#>
<cfset GetfileName = #ListLast(convertfile,"\")#>
<cfquery name = "QUpdateFiles" datasource="#strDSN#" username="#strUID#" password="#strPWD#">
update Files
SET
Description =
<cfif (StructKeyExists(form,"FileDescription" & x) && len(trim(Form["FileDescription" & x])) && #variables["Descp" & x]# neq '')>
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#variables["Descp" & x]#">,
<cfelseif isDefined("QGetFileName") and QGetFileName.RecordCount gt 0>
'#GetfileName#',
<cfelse>
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#ii#">,
</cfif>
<cfif StructKeyExists(form,"AttachFile" & x) && len(trim(Form["AttachFile" & x]))>
UploadedFile = <cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#ToBase64(variables.filelocation & cffile.serverfile)#">,
uploadedasbinary = <cfqueryparam cfsqltype="cf_sql_blob"
value="#FileReadBinary(variables.filelocation & cffile.serverfile)#">,
</cfif>
CreatedDate = <cfqueryparam cfsqltype="cf_sql_date" value="#Now()#" />
where FileID = #variables["FileID" & ii]#
</cfquery>
<cfelseif (StructKeyExists(form,"AttachFile" & ii) && len(trim(Form["AttachFile" & ii]))) && #Form["AttachFile" & ii]# neq "">
<cfloop list="#variables.Attachments#" index="ii">
<cfset x++/>
<cfquery name = "QInsertFiles" datasource="#strDSN#" username="#strUID#" password="#strPWD#">
Set Nocount On;
<cfif (StructKeyExists(form,"AttachFile" & x) && len(trim(Form["AttachFile" & x]))) >
INSERT INTO Files
(FileName,Description,UploadedFile,IssueID,Status,CreatedDate,uploadedasbinary)
VALUES
(
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#x#">,
<cfif (StructKeyExists(form,"FileDescription" & x) && len(trim(Form["FileDescription" & x])) && #variables["Descp" & x]# neq '')>
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#variables["Descp" & x]#">,
<cfelse>
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#ii#">,
</cfif>
<cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#ToBase64(variables.filelocation & ii)#">,
#IssID#,
1,
<cfqueryparam cfsqltype="cf_sql_date" value="#Now()#" /> ,
<cfqueryparam cfsqltype="cf_sql_blob"
value="#FileReadBinary(variables.filelocation & ii)#"> )
</cfif>
</cfquery>
</cfloop>
</cfif>
</cfloop>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
ASKER
gdemaria - I need your help please. ( I have an open question that you are the only one that can help me with, because we worked on it together. So, you know what I'm looking for.)
Here is a link to the question:
https://www.experts-exchange.com/questions/28422355/record-per-page.html