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

Uploading Multiple Images

New Here ,
Jul 31, 2007 Jul 31, 2007

Copy link to clipboard

Copied

Hello,
The answer to this question is most likely sitting right in front of me, but I can not figure this out. This is an image upload page that uploads multiple images to my SQL db. (I am using CF 7.0) I have a form called "pick.cfm" that the user enters the number of images to be uploaded. This page also sets the #cookie.micro# in the code referenced below. #cookie.micro# is the number of images to be uploaded.

The problem is, if I upload two images, for example, named "abc.jpg" and "def.jpg" the filenames are inserted into the database as "abc.jpg" (correct) and "abc1.jpg (not correct).

This is the form:

<cfform action="testingform_action.cfm" enctype="multipart/form-data" method="post">


<cfset numberoffields = #cookie.micro#>



<cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
<cfset filename2 = "form.file">
<cfinput type="File" name="micro" value="#variables.filename2#"/><br />


</cfloop>


<cfinput type="Submit" name="upload" value="upload">

</cfform>



This is the action page:


<cfloop index="i" from="1" to="#cookie.micro#" step="1">

<cffile destination="d:\Inetpub\wwwroot\pulse\pathology\pia\images\"
action="upload"
accept="image/*"
nameconflict="makeunique"
filefield="micro">




<cfquery datasource="pathimage" name="insertimage">
Insert into images (filename) VALUES ('#file.ServerFile#')
</cfquery>



</cfloop>


What is causing this? I am sure it is simple, but I can not figure it out. ANY advice you could give would be so much appreciated!

Alison
TOPICS
Advanced techniques

Views

243

Translate

Translate

Report

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

Guide , Jul 31, 2007 Jul 31, 2007
I would guess its because all of the file fields all have the same name. Try naming them dynamically: micro1, micro2, micro3, etc.

A few minor comments about the code

- Afaik, setting the VALUE has no effect for input fields when type="file"
- FILE is deprecated. Use CFFILE.ServerFile instead
- You don't need # signs here <cfset numberoffields = #cookie.micro#>

Not tested

Votes

Translate

Translate
Guide ,
Jul 31, 2007 Jul 31, 2007

Copy link to clipboard

Copied

I would guess its because all of the file fields all have the same name. Try naming them dynamically: micro1, micro2, micro3, etc.

A few minor comments about the code

- Afaik, setting the VALUE has no effect for input fields when type="file"
- FILE is deprecated. Use CFFILE.ServerFile instead
- You don't need # signs here <cfset numberoffields = #cookie.micro#>

Not tested

Votes

Translate

Translate

Report

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
New Here ,
Aug 02, 2007 Aug 02, 2007

Copy link to clipboard

Copied

LATEST
Thank you SO MUCH for your help! This worked like a charm. I appreciate your time.

Votes

Translate

Translate

Report

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
Documentation