8 Replies - 347 Views - Last Post: 16 October 2017 - 07:28 AM Rate Topic: -----

#1 Gates  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 31-March 17

Cfloop problem

Posted 13 October 2017 - 05:37 AM

Hi, i'm using Aurigma image uploader to upload photos for a used tire website and i want to have specific names for the photos so they dont get overwrite so i use my clientID and the next ID in my tire databasse plus i want to add the loopcount and the end so i upload the image then i rename them but my index i stays a 0 in destination = "D:\MYPATH\#clientID#_#nextID#_#i#" i only get 1 out of my 5 images in my directory somthing like 12_176_0.jpg and its the last one that got uploaded so why is my "i" index not adding up ?


<cfset fileCount=(#Form.PackageFileCount#-1) />
<cfloop index="i" from="0" to="#fileCount#">
    <cfset name="#Form["SourceName_#i#"]#"/>

 

 
    <!--- Get source file and rename/save it to disk. --->

    <cffile action="UPLOAD" filefield="File0_#i#"
        destination="D:\MYPATH\"
        nameconflict="MakeUnique">

        <cfimage action = "resize"
            width="800"
            height="600"
            source = "D:\MYPATH\#name#"
            destination = "D:\MYPATH\#clientID#_#nextID#_#i#.jpg"
            overwrite = "yes">
 

    <cffile
        action = "delete"
        file = "D:\MYPAT\#name#">
</cfloop>





Thanks

This post has been edited by Craig328: 13 October 2017 - 07:24 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Cfloop problem

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 2024
  • View blog
  • Posts: 3,609
  • Joined: 13-January 08

Re: Cfloop problem

Posted 13 October 2017 - 07:28 AM

Hi Gates.

First thing I'd do if it were my code is to output the value of "fileCount" that you set on line 1. What you're doing there seems kind of an awkward (but maybe valid all the same) way of setting the value for that variable. Also, it's a good habit to scope your variables because words like "filecount" and especially "name" can be reserved words for tags and/or the platform.

But check the value of filecount and make sure that it's a value you expect it to be.
Was This Post Helpful? 0
  • +
  • -

#3 Gates  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 31-March 17

Re: Cfloop problem

Posted 13 October 2017 - 07:52 AM

The value is good if i upload 5 images filecount = 5
Was This Post Helpful? 0
  • +
  • -

#4 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 2024
  • View blog
  • Posts: 3,609
  • Joined: 13-January 08

Re: Cfloop problem

Posted 13 October 2017 - 08:32 AM

Okay. This is now "Bug Squashing 101". :bigsmile:

Next step: comment out everything from lines 3 through 24 and add <cfoutput>Filecount: [#fileCount#]<br></cfoutput> and then a <cfabort> after the </cfloop>.

This will simply put out the incrementing variable value so we can ensure that the value is being properly gen'd. One small step at a time here.

Do that and come back and tell me you see the value incrementing and we'll go to the next step.
Was This Post Helpful? 0
  • +
  • -

#5 Gates  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 31-March 17

Re: Cfloop problem

Posted 13 October 2017 - 09:58 AM

I cant do that take a look at this :

http://pneuusage.ca/upload/

This is the the page where you load the images :

Index.cfm

*****************************************************************************


<cfprocessingdirective pageEncoding="UTF-8" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test
</title>

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link href="Scripts/css/aurigma.htmluploader.control.css" rel="stylesheet" type="text/css" />
<link href="Styles/css.css" rel="stylesheet" type="text/css" />
<link href="bower_components/bootstrap/dist/css/bootstrap.css" rel="stylesheet"/>

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->

<!--[if lt IE 9]>

<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>

<![endif]-->

<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="Scripts/aurigma.imageuploaderflash.min.js" type="text/javascript"></script>
<script src="Scripts/aurigma.htmluploader.control.js" type="text/javascript"></script>

<script type="text/javascript">



$().ready(function(){

var uploader = $au.imageUploaderFlash({

id: 'Uploader1',

licenseKey: '77FF1-00001-78280-0002D-132E8-3520C7',

width: '100%',

height: '450px',

uploadButtonText: "TÚlÚcharger",

enableDescriptionEditor: false,

enableRotation: true,

converters: [

{ mode: '*.*=SourceFile' },

{ mode: '*.*=Thumbnail', thumbnailFitMode: 'Fit', thumbnailWidth: '120', thumbnailHeight: '120' }

],

uploadSettings: {

actionUrl: 'Upload.cfm',

},



topPane: {

visible: false,

},

uploadPane: {

addFilesButtonText: "ajoutez les photos",

},

statusPane: {

filesToUploadText: "<font color='#7a7a7a'>Fichier</font> {0}",

noFilesToUploadText: "<font color='#7a7a7a'>Aucun fichier</font> {0}",

},

flashControl: {

codeBase: '../Scripts/aurigma.imageuploaderflash.swf',

bgColor: '#f5f5f5'

},

restrictions: {

maxFileSize: 31457280,

fileMask: [

['Images (*.jpg)', '*.jpg']

],

minFileCount: 5, maxFileCount: 5},

messages: { tooFewFiles: 'Vous devez soumettre 5 photos.',

maxFileCountExceeded: 'Vous devez soumettre 5 photos.'

},

});

$("#uploader").html(uploader.getHtml());

});



</script>



<script>
$().ready(function(){
if (typeof $au !== 'undefined' && !!$au.debug) {
$("#uploader-version").text($au.debug().version());
}
});

</script>

</head>
<body>



<div class="container">
<div class="col-md-10 col-lg-10 col-sm-10 col-md-offset-1 col-lg-1-offset col-sm-offset-1">
<div class="row">
<div class="panel panel-primary">
<div class="panel-heading">

</div>
<div class="panel-body" id="sample-body">
<div id="uploader"></div>
</div>
<div class="panel-footer">
</div>
</div>
</div>
</div>
</div>


<!-- Bootstrap core Javascript

================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>

</body>
</html>



*****************************************************************************

This is the entire upload.cfm page

*****************************************************************************

<CFQUERY NAME="getinfo" datasource="MyDNS">
SELECT *
FROM company
WHERE no_client = 1
</cfquery>





<CFQUERY NAME="thelastid" datasource="MyDNS">
SELECT id
FROM tires
ORDER by id desc
</cfquery>



<cfset lastcount = 0>
<cfset lastid = #thelastid.id# + 1>


<cfprocessingdirective pageEncoding="utf-8" />

<!---This variable specifies relative path to the folder, where the gallery with uploaded files is located.

Do not forget about the slash in the end of the folder name.--->

<cfset galleryPath="UploadedFiles/" />
<cfset absGalleryPath="#ExpandPath(galleryPath)#" />
<cfset absThumbnailsPath="#absGalleryPath#Thumbnails/" />


<!---Create XML file which will keep information about files (image dimensions, description, etc).
XML is used solely for brevity. In real-life application most likely you will use database instead.--->


<!---Get total number of uploaded files (all files are uploaded in a single package) and
iterate through uploaded data and save the original file, thumbnail, and description.--->



<cfset fileCount = Form.PackageFileCount - 1 />
<cfloop index="i" from="0" to="#fileCount#">
<cfset name="#Form["SourceName_#i#"]#"/>




<!--- Get source file and save it to disk. --->

<cffile action="UPLOAD" filefield="File0_#i#"
destination="#absGalleryPath#"
nameconflict="MakeUnique">



<cfimage action = "resize"
width="800"
height="600"
source = "#galleryPath#\#name#"
destination = "D:\MyPath\#cookie.no_client#_#lastid#_#i#.jpg"
overwrite = "yes">



<cffile
action = "delete"
file = "D:\MyPath\UploadedFiles\#name#">



<cfset sourceFileName="#replace(URLEncodedFormat(serverFile), '%2E', '.', 'ALL')#" />

<!--- Get first thumbnail (the single thumbnail in this code sample) and save it to disk. --->

<cfset thumbnailFileName=Form["File1Name_#i#"] />

<cffile action="UPLOAD" filefield="File1_#i#"
destination="#absThumbnailsPath#"
nameconflict="MakeUnique"/>

<cffile action="rename"
source="#serverDirectory#/#serverFile#"
destination="#thumbnailFileName#"
attributes="normal"/>

<!---Save file info.--->
<cfset thumbnailFileName="#URLEncodedFormat(thumbnailFileName)#" />


</cfloop>


<cfoutput>#fileCount#</cfoutput>

*****************************************************************************
Was This Post Helpful? 0
  • +
  • -

#6 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 2024
  • View blog
  • Posts: 3,609
  • Joined: 13-January 08

Re: Cfloop problem

Posted 13 October 2017 - 10:15 AM

No Gates. All you need to do is to make the changes I suggested at the end of that ridiculously long code block. I'm willing to help you troubleshoot it...but I'm not gonna swallow the entire code module and do it for you.

Essentially, what you do is address each variable in turn and see where your issue is. Add things back in piece by piece as you confirm that each step in the upload process is working to your expectations.

Try working your way through it like that and eventually you'll discover the issue. 100% of the time it works 75% of the time. :D

Good luck and post back here once you've isolated your issue.
Was This Post Helpful? 0
  • +
  • -

#7 Gates  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 31-March 17

Re: Cfloop problem

Posted 13 October 2017 - 11:45 AM

i did it and nothing happens in the Aurigma Code

uploadSettings: {
actionUrl: 'Upload.cfm',
},



Is suppose to be

uploadSettings: {
actionUrl: 'Upload.cfm',
redirectUrl: 'Gallery.cfm'
},

So upload.cfm just loads to transfert the files I dont see the anything
Was This Post Helpful? 0
  • +
  • -

#8 Gates  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 31-March 17

Re: Cfloop problem

Posted 16 October 2017 - 06:34 AM

I got it to work i found in Aurigma a field that has the value i was looking for form.PACKAGEINDEX its working now.

Thanks
Was This Post Helpful? 1
  • +
  • -

#9 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 2024
  • View blog
  • Posts: 3,609
  • Joined: 13-January 08

Re: Cfloop problem

Posted 16 October 2017 - 07:28 AM

Good to hear! Congrats!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1