Skip to main content
February 26, 2007
Answered

Using a Forward Slash (/) in CFFILE Destination

  • February 26, 2007
  • 3 replies
  • 2793 views
Hi everyone,
I couldn't find this anywhere in the forums (at least not searching for "cffile forward slash", "cffile /", or "cffile destination") and hope I'm posting this in the correct place (please let me know if not). I need to use a forward slash (/) in the name of a file using cffile, but when I try to set destination = "c:\directory\file/name.txt" cf throws an exception and tells me that the system can't find the "c:\directory\file\" directory. Is there a way to froce ColdFusion to interpret the forward slash as part of the file name instead of a directory structure character? By the way I'm using ColdFusion 6.1 Standard Edition on a Windows box (obviously).
This topic has been closed for replies.
Correct answer Newsgroup_User
quote:

Originally posted by: Newsgroup User
Almal wrote:
> Thanks for the quick reply.
>
> It's unfortunately a naming convention for the system to which the file is
> being uploaded.

very strange.... are you sure about that? as Adam said, a forward (or
backward) slash is not a legal character in a file name, at least not on
any systems i know...



That was always my understanding also, at least on *nix systems (I'm not too familiar with Windows). I assumed they were using some sort of file system in which you could use it, but doing a little more research it doesn't seem to be a legal file name character on any Windows systems either. I'm going to contact them and let them know. This is looking more and more like a mistake on their end (and my end for not doing my Windows research).

By the way, just to clarify, the file needs to be named according to an encoded ID that happens to have a forward slash in it.

Thanks for the responses, I will post to let you know the outcome and mark this as answered.

One can actually use forward slashes in file names in *nix systems. It's
clever enough to be able to differentiate between "part of a file name",
and "part of the path". From memory, one needs to enclose the file name in
quotes or some other delimter, though.

But one *cannot* use a fwd slash on Windows.

--
Adam

3 replies

Inspiring
February 27, 2007
I just tried again. The os is AIX 5.2

I could never get a forward slash into a file name. This is not surprising because unix uses forward slashes for addressing. I tried escaping with single quotes, double quotes, one backslah and two backslashes

I could get a backslash into a name by escaping it with another one. But that wasn't the original question.
February 27, 2007
Just tried doing it with mv and cp on OSX (which is BSD based) and there doesn't appear to be any way to do it from the command line. In reference to using delimeters to do it, I was doing it from OSX and didn't notice that the forward slash was replaced with a colon (:) in the actual filename. So apparently you can not use forward slashes even if you escape them or enclose the file name in quotes, at least on BSD.

Thanks again, all.
Inspiring
February 26, 2007
A fwd slash is not a legal character in a file name.

--
Adam
Inspiring
February 26, 2007
what's the action of cffile? read? upload?
i think with action=read you may be able to use URLEncodedFormat() on
the file name to get over the issue (I can't test it, though, since
windows won't let you save a file with / in the name...)

with action=upload i am afraid there is no way to fool CF...

how did you end up with such file name anyway?

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
February 26, 2007
Thanks for the quick reply.

It's unfortunately a naming convention for the system to which the file is being uploaded. In the original cffile tag, the action attribute was set to write. The end result of the script is an upload to a remote server using cfftp. I got as far as realizing I could name the file something different on my server (which is working) and then name it according to the naming convention in cfftp (which isn't working). So now I'm trying to use <cfftp action="putfile" remotfile="file/name.txt"> which is returning:

An exception occurred when performing the FTP putfile operation.

The cause of this exception was that: 550 rename: No such file or directory. .

I've also tried putting the file with the working file name and then using <cfftp action="rename" new="file/name.txt"> but it's giving me the same error (in other words, the remote server seems to be searching for the "/file/" directory). Is there anything I can do within the script to fix this or is this an inherent limitation of ftp?

Any ideas?