Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

uploading multiple files

Community Beginner ,
Dec 18, 2008 Dec 18, 2008
Hello - I have a CF form that allows users to upload two files, a document and a photo:

Upload document: <INPUT NAME="upFileName" SIZE="30" TYPE="FILE">
Upload photograph: <INPUT NAME="upPhotoName" SIZE="30" TYPE="FILE">

I need to store both the name of the document and the name of the photo in an MS SQL database. However, if I insert to the database using the #File.ServerFile# variable, only one of the file names is stored, of course. What is the best way to have two different variables representing the two different files? Thanks!!



TOPICS
Getting started
496
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 18, 2008 Dec 18, 2008
coolidge wrote:
> Hello - I have a CF form that allows users to upload two files, a document and
> a photo:
>
> Upload document: <INPUT NAME="upFileName" SIZE="30" TYPE="FILE">
> Upload photograph: <INPUT NAME="upPhotoName" SIZE="30" TYPE="FILE">
>
> I need to store both the name of the document and the name of the photo in an
> MS SQL database. However, if I insert to the database using the
> #File.ServerFile# variable, only one of the file names is stored, of course.
> What is the best w...
Translate
LEGEND ,
Dec 18, 2008 Dec 18, 2008
coolidge wrote:
> Hello - I have a CF form that allows users to upload two files, a document and
> a photo:
>
> Upload document: <INPUT NAME="upFileName" SIZE="30" TYPE="FILE">
> Upload photograph: <INPUT NAME="upPhotoName" SIZE="30" TYPE="FILE">
>
> I need to store both the name of the document and the name of the photo in an
> MS SQL database. However, if I insert to the database using the
> #File.ServerFile# variable, only one of the file names is stored, of course.
> What is the best way to have two different variables representing the two
> different files? Thanks!!

The file structure contains the data of the *last* <cffile
action="upload"...> call. So you can either use this by doing one
<cffile...> update your database with that data, then do the next
<cffile...>.

Since CF7, the <cffile...> tag has the 'result' paramater that allows
you to name a different variable to contain the results of a <cffile
action="upload"...> operation. So you can use this to give the two
upload actions different variable names and then use those in your
database update transactions.


<cffile action="upload" result="documentFile"...>
<cffile action="upload" result="photoFile"...>


<cfoutput>
#documentFile.ServerFile#
#photoFile.ServerFile#
</cfoutput>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2008 Dec 18, 2008
LATEST
Result parameter is the answer...thanks so much!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources