Skip to main content
Inspiring
November 6, 2008
Answered

Trouble uploading file with specific filename

  • November 6, 2008
  • 16 replies
  • 1474 views
I have built a gui that allows the user to enter a news release (using IRite for editing) and have it upload to the server. It needs to be uploaded to the server using a specific name, which the user selects from a drop-down. It's not working and I'm not sure why. Can someone take a look at my code and see if they can spot something? Thanks.
This topic has been closed for replies.
Correct answer Newsgroup_User
assuming, as in your original post, you are using a textarea with
NAME="newsrelease" for text input, all you need is:

<cffile action="write" destination="#expandpath('..\news\') &
form.filename#" output="#form.newsrelease#">

if your drop-down filename box contains only the name part and no
extension (i.e. "mynews" instead of "mynews.cfm"), then add & '.cfm'
after form.filename in the destination attribute of cffile tag above.


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

16 replies

Inspiring
November 6, 2008
you are NOT uploading any files to use <cffile action="upload">!

you need action="write" instead.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
tgooldAuthor
Inspiring
November 6, 2008
Sorry, I forgot to answer your question completely.
"not working" means that the file is not being uploaded to the database.
tgooldAuthor
Inspiring
November 6, 2008
Here's what I've got set up. A two step process.
First page collects information that writes to a database, which includes a filename.

Second page. Has an area that the user can type in a news release and also a drop down that they select a filename (which they entered into the database on the previous page).

I want the app to upload the news release in cfm format to the web server, using the filename that I selected from the drop down box. I took snapshots of what the interface looks like, but don't see a place to attach them. I thought it would help you understand what I'm trying to do.
Inspiring
November 6, 2008
tgoold wrote:
> It's not working

Help us out here ;-) What does "not working" mean? What it is actually happening versus what you expect to happen. If you are receiving an error, post the error message.
tgooldAuthor
Inspiring
November 6, 2008
So are you saying that I can't take the text that I've written in the form and turn it into a cfml file?
November 6, 2008
I think the "filefield" parameter is valid only for actual file fields (input type=file). For this you should use the actual filename (<cffile file="#filename#"...>.

(On second thought the file= parameter doesn't work when action=upload - I believe you actually have to have a file field to allow the user to browse for the file. Otherwise the server can't access the file on the client. Looking at this closer, what you need is both the file selection field (for the destination name) and an input of type=file (to select the file on the client). The file on the client doesn't have to be named the same as the selected destination.)

Ken