Title:
Bug 80701:Using CF7 I can successfully upload a PDF document and download it / view it etc
| View in TrackerStatus/Resolution/Reason: Closed/Withdrawn/
Reporter/Name(from Bugbase): Gavin Baumanis / Gavin Baumanis (GavinBaumanis)
Created: 11/16/2009
Versions: 9.0
Failure Type: Unspecified
Found In Build/Fixed In Build: 0000 /
Priority/Frequency: Major / Unknown
Locale/System: English / Platforms All
Vote Count: 0
Problem:
Using CF7 I can successfully upload a PDF document and download it / view it etc.Using CF9 I can successfully upload a PDF document but cannot download it.The browser reports the file is corrupt.This happens with IE7, 8 and FF3.5
Method:
I provide the following code that is used for upload and retrieval;Please let me know if there is any more information that I can provide for you.This bug is currrently stopping us from using CF9 in production.Upload (Submit page):=-=-=-=-=-=-=-<!--- check for a valid session ---><cfif not isdefined("session.username")><!--- there is no valid session. relocate to a custom error page ---> <cflocation url="noSession.cfm"><cfelse><!--- set the Max file size to 10 MB ---><cfset var_filesizebytes = 10485760><!--- initialise the variable we will use to determine if an error has occurred or not ---><cfset fileerror = 'false'><!--- Check for a valid file name ---><cfif form.formfilename neq ""><!--- check to see if the filename was entered. ---><cfset file_name = getFileFromPath(theFile)> <!--- set the file name ---><cfset file_type = listLast(file_name,".")> <!--- set the doc type ---><cfif file_name eq #file_type#><!--- because of the way we obtain the file extension from the filename, if they are the samethen a file extension was not provided. alert the user to this fact and ask them to correct it ---><script language="javascript" type="text/javascript">alert('You have chosen a filename without a valid file extension.\n\nPlease ensure the file you add has an extension!');history.back();</script><cfabort></cfif><!--- end of extension check ---><!--- filename was not entered, alert the user to this fact and ask them to correct it ---><cfelse><script language="javascript" type="text/javascript">alert('The filename may NOT be left blank.\n\nUse the BROWSE button to correct this!');history.back();</script><cfabort></cfif><!--- end of filename check ---><!--- there is no error. continue processing ---><cfif fileerror eq "false"><!--- Increment FilesAdded var so that the cffile can work ---><cfset session.var_numfilesadded = session.var_numfilesadded + 1><!--- Try to create the file in the servers memory, Check for the following errors while trying toadd to the server's memory.0 byte size fileGT than max file size (10 MB)if an error occurs return to add file window ---><cftry><!--- read the file into the server's RAM.---><cffileaction="READBINARY"file="#form.formfilename#"variable="session.attached_file#session.var_numfilesadded#"><!--- Set the variables that allow us to evaluate the actual file ---><cfset filetest = "session.attached_file" & #session.var_numfilesadded#><cfset filetest2 = evaluate(#filetest#)><!--- Check for file size of 0 Bytes ---><cfif len(filetest2) eq 0><cfthrowtype="nofile"message="Invalid File. Please use the BROWSE button to correct this."></cfif><!--- Check for file size of Greater than 10MB ---><cfif len(filetest2) GT #var_filesizebytes#><cfthrowtype="bigfile"message="File Size is greater than 10 MB."></cfif><!--- if a fileerror occurred then display the error and go back to the form. ---><cfcatch type="any"><cfset fileerror = 'true'><cfset session.var_numfilesadded = session.var_numfilesadded - 1><cfoutput><script language="javascript" type="text/javascript">alert('#cfcatch.message#');history.back();</script></cfoutput></cfcatch></cftry><!--- if there was no error (fileerror eq false, then place all variable values into the array.NOTE: The actual array's contents are added into the DB by a file add function in JOBS.CFC ---><cfif fileerror eq 'false'><!--- set up the session variables required for the array ---><cfset thefile = "#form.thefile#"><cfset file_desc = #form.file_description#> <!--- set the file description ---><cfset file_name = getFileFromPath(theFile)> <!--- set the file name ---><cfset file_type = listLast(file_name,".")> <!--- set the doc type ---><!--- now write the variables to the arrary ready for multiple file addidtion---><cfset session.filearray[#session.var_numfilesadded#][1] = "#form.formfilename#"><cfset session.filearray[#session.var_numfilesadded#][2] = "#file_name#"><cfset session.filearray[#session.var_numfilesadded#][3] = "#file_type#"><cfset session.filearray[#session.var_numfilesadded#][4] = "#file_desc#"><cfset session.filearray[#session.var_numfilesadded#][5] = "#len(filetest2)#"><cfset session.filearray[#session.var_numfilesadded#][6] = "#form.documenttypeid#"><cfset session.filearray[#session.var_numfilesadded#][7] = "#form.frmPatientID#"><!--- return to the add_file template---><cflocation url="scandocadd.cfm?#form.origQueryString#" ></cfif><!--- End FileError IF STATEMENT ---></cfif><!--- End Validation IF STATEMENT ---></cfif><!--- end of session checking --->Retrieval Page:=-=---=--=--=--=<html><head><title>Incoming Correspondence - Download page</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><cfoutput><cfquery name="scandocSelect" datasource="#gvdb#">SELECT * FROM patientscandocWHERE id=#url.docid#</cfquery> <cfinclude template="/aushared/scripts/cfm/udf_localURL.cfm" /> <cfset relativeFile = "../correspondence/#scandocSelect.filename#"> <cfif FileExists(ExpandPath(relativeFile))><iframe src="#relativeFile#" height="100%" width="100%" frameborder="0" vspace="0" hspace="0"> <cfelse><!--- Set the header values. ---><cfheadername="content-length"value="#ArrayLen(scandocSelect.file)#"/><!---Set the correct file name.Filename cannot have whitespaces otehrwise it is unknow (so replace with underscores---><cfheadername="content-disposition"value="inline; filename=""#scandocSelect.filename#"""/><!--- Stream the binary image data to the user. ---><cfcontenttype="application/*"variable="#scandocSelect.file#"/></cfif> </cfoutput></body></html>
Result:
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3040417
External Customer Info:
External Company:
External Customer Name: Gavin Baumanis
External Customer Email: 5D5F35544462E7E699201549
External Test Config: 11/16/2009
Attachments:
Comments: