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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

handling file attachment with CFCONTENT - help 1

Status
Not open for further replies.

smbayo

Programmer
Jun 26, 2001
6
0
0
US
I am building a email application in CF and using CFCONTENT to attachments to messages. The problem with this is that if the name of the attached file has spaces in it Cf flags an error that the file does not exist.

How do I get around this problem?
 
Thanks dasniper but i have already tried #URLEncodedFormat(<name>)# - still doesn't work. Could it be a problem with CF Server 4.0.1?
 
Hey Smbayo,

If you want to post your code, I'll take a look and see if I can duplicate it and possibly fix the problem.

GJ
 
Here's the code:

This code reteives the attachment and generates a link to download the file in the &quot;view message&quot; page ......
Code:
<CFLOOP FROM=&quot;1&quot; TO=&quot;#ListLen(Message.Attachments,' ')#&quot; INDEX=&quot;CurrItem&quot;>
   <CFOUTPUT>
     <CFSET FileName = &quot;#AttachDir##URLEncodedFormat(GetFileFromPath(ListGetAt(Message.AttachmentFiles, CurrItem, '	')))#&quot;>
<A HREF=&quot;getfile.cfm/#GetFileFromPath(Filename)#?Filename=#URLEncodedFormat(Filename)#&quot;>#ListGetAt(Message.Attachments, CurrItem, &quot;	&quot;)#</A>

   </CFOUTPUT>
</CFLOOP>
... and use this to access the file when you click on the link .....

Code:
<cfcontent type=&quot;application/unknown&quot; FILE=&quot;#URL.Filename#&quot; deletefile=&quot;No&quot;>
 
Hey Smbayo,

I apologize for not getting back to you sooner but I've had a busy week with very little spare time. I've checked into this and it appears that you're going to need to use the old 8.3 dos naming convention to get this to work.

<cfcontent type=&quot;application/unknown&quot; FILE=&quot;d:\test1~1.txt&quot; deletefile=&quot;No&quot;>

The code above should return a file named &quot;d:\test 1.txt&quot;. The problem is that you have to know the 8.3 name ahead of time since you can't determine it just from the original filename. If the list of files is fixed, just create some type of translation to translate the original name into the 8.3 name. If this isn't possible, the only workaround I can think of is to do a DOS based &quot;rename&quot; command to rename the file to one without spaces. You can do this in CF 4.5 with the <cfexecute> command. I would rename the file with all spaces removed as CF will work with file names longer than the old 8 character limit as long as they don't have spaces. I don't see any easy workaround other than that.

Good luck,
GJ
 
thanks GJ ..... it's about the only work around that comes to mind too. however, CF4.0 does not give me many options. I will be upgrading to 5.0 soon. Hopefully that should give me some leverage.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top