Alex Rivera | Logout

ColdFusion: get the name of a file before uploading

Asked 2009-05-13T23:40:58.063
15

How can I get the filename of a file before I call the

<cffile action = "upload">

? I can get the filename of the temp file, but not of the actual filename. In PHP land I can use the $_FILES superglobal to get what I want - but as far as I can tell no such thing exists in ColdFusion.

I can get the filename client-side but would really want to do this server side.

Thanks

Edit
Report

1 Answer

7

I don't know of a way to find out before calling cffile, but there may be a workaround.

When you call <cffile action="upload"> you can specify a result using result="variable". So, call the upload with the destination as a temp file. Your result variable is a struct which contains the member clientFile, which is the name of the file on the client's computer.

Now, you can use <cffile action="move"> to do whatever it is you need to do with the original filename.

answered 2009-05-14T00:28:00.280

Your Answer