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

fileOpen, fileRead etc.

Status
Not open for further replies.

CTekMedia

Programmer
Oct 5, 2001
634
0
0
US
I'm using the new file functions from CF8 to upload files in order to avoid the out of memory problems caused by CFFILE. It works fine if I know the file type that is being uploaded as I rename the files anyway.

But now I have a need to upload files of unknown types. With CFFILE there was no problem - the tag captured the original name of the file (as opposed to the temporary name) and saved it with the correct name and extension.

<CFFILE
ACTION="upload"
FILEFIELD="#FORM.fileFieldName#"
NAMECONFLICT="makeunique"
DESTINATION="#SomePath#">

So with an HTML input control with the attribute type="file" if I browse my computer and select "xyz.pdf" to upload - when you look at the form value it actually shows something like "C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\ instead.

CFFILE saved the file with the original name. Using fileCopy my file gets saved as neotmp48974.tmp.

Thoughts?

How do I get the original file name from the html form element rather than the temp file name?

Thanks!


 
I think you may be confused about FileCopy(). It is not intended as a replacement for cffile action="upload". For uploads, you must use cffile to the original file information.

Since the file is already on the server, calling cffile action="upload" does little beyond moving the file and returning the file details. So there is no reason not to use it. After that, you can use FileCopy() or whatever file function you wish.

----------------------------------
 
I'm using the new file functions from CF8 to upload files in order to avoid the out of memory problems caused by CFFILE.

That is more for read operations. The new functions let you read in a single line of a file, rather than load the entire file into memory.

----------------------------------
 
Of course. The file (doc) is sent in the http packet. CF has nothing to do with it.

Ug.

The joys of public stupidity.

Thanks for the answer.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top