Skip to main content
Inspiring
April 22, 2008
Question

cffile upload

  • April 22, 2008
  • 1 reply
  • 257 views
I have the following. I am able to upload and when I look in the testlibrary, the uploaded file is there, so this part works. I then wan to retrieve the file, but nothing comes back. My cfoutput shows blank. What am I doing wrong ?



<cffile action="upload"
filefield="upload_file_name"
destination="d:\inetPub\wwwroot\file_2007\library\TestLibrary\"
nameconflict="makeunique">

<!--- Define the library name --->
<cfset LibraryDirectory = "d:\inetPub\wwwroot\file_2007\library\TestLibrary">

<!---Read the file from the library --->
<cfdirectory
action="list"
directory="#LibraryDirectory#"
name="GetFiles"
filter="*.*"
sort="datelastmodified">

<!--- Perform a loop for each file --->
<cfloop query="getfiles">
<cfoutput>upload file name is #qryGetfile.upload_file_name#</cfoutput>
    This topic has been closed for replies.

    1 reply

    Inspiring
    April 22, 2008
    trojnfn wrote:
    > I have the following. I am able to upload and when I look in the testlibrary,
    > the uploaded file is there, so this part works. I then wan to retrieve the
    > file, but nothing comes back. My cfoutput shows blank. What am I doing wrong ?

    well, for starters, you are using #qryGetfile.upload_file_name# in your
    output. where did that come from? your cfdirectory returns data into
    GetFiles variable. and it DOES NOT have a column named 'upload_file_name'.

    if all you want is the name of the uploaded file, then all you need is
    #cffile.serverfile# - this will return the name of file on server for
    the file processed by the last <cffile> tag on the page.

    if you need to use cfdirectory for some reason, you can provide
    #cffile.serverfile# as FILTER attribute so it retrieves only that file.


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