ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 1st, 2005, 09:38 AM
Shmoo Shmoo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 38 Shmoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 43 m 17 sec
Reputation Power: 4
CFFILE upload/read error with spaces in filename

I have a little thing where users upload a tab-delimited .txt file using CFFILE upload and read. It works perfectly UNLESS the text file the user uploads has a space in the file name.

I'd like to either make it so the file uploaded DOESN'T have a space in the filename (CFFILE rename?), or just produce a simple error message explaining to the user that filenames can't have spaces in them (something more friendly than the ugly CF error message). Either one would make me happy...this is my first time playing with CFFILE, so I'm not sure what can be done, or what's easier. Here the code if it helps:

Code:
<cffile action="upload"
		    destination="/home1/web-docs-443/files"
		    nameConflict="overwrite"
			mode=777
		    fileField="FiletoUpload">
		
		<cffile action="read"
		  file="/home1/web-docs-443/files/#cffile.ClientFileName#.#cffile.ClientFileExt#"
		  variable="UploadedFile">


Any suggestions/help would be much appreciated, thanks

Reply With Quote
  #2  
Old April 1st, 2005, 11:04 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
You could use Javascript on the client to ensure the file has no space in the name. You could use the CFML find or REFind functions to ensure the file name has no space after it is uploaded. You can also use cftry/cfcatch to catch any errors and display friendly error messages to the user (that's what exception handling is for).
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old April 1st, 2005, 11:52 AM
Shmoo Shmoo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 38 Shmoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 43 m 17 sec
Reputation Power: 4
I must be missing something, because whenever I try to use functions (Find, Replace, etc) on the "FiletoUpload" variable it's checking the CONTENTS of the text file instead of the actual filename(?)

For example, just to test, before all the CFFILE stuff I put

<CFOUTPUT>#FiletoUpload#</CFOUTPUT>

Shouldn't that show the filename instead of the contents of the actual file? Here's the form from the page before where the user browse's their PC and selects the file to upload...

Code:
<FORM action="self-report-check.cfm" enctype="multipart/form-data" method="post">
Enter the complete path and filename of the tab-delimited text file to upload:<BR>
  <INPUT TYPE="file" NAME="FiletoUpload" SIZE="45">
  
<BR><BR><INPUT TYPE="Submit" VALUE="Upload">
</FORM>


I did put some CFTRY tags around the CFFILE stuff on the next page, which of course caught the error and created a better looking error screen, but this still seems too easy to be difficult.

Reply With Quote
  #4  
Old April 1st, 2005, 12:57 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
Do a cfdump of the cffile structure to see what variables are available.

And personally I think using cftry/cfcatch is very easy. Remember it's up to you to handle exceptions and a space in the file name is an exception. That's what try/catch is there for.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > CFFILE upload/read error with spaces in filename


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway