Copy link to clipboard
Copied
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 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>
****************************************************************************
And i also what to update my database with the name of the photos i have 5 field named photo, photo1, photo2, photo3, photo4 once i get the loopcount i was thinking of using something like this but how do i get the photo1, photo2 etc... in there ?
<cfquery name="updatetData" datasource="myDNS">
UPDATE INTO usedtires
WHERE ID = #lastid#
(photo)
VALUES (
<cfqueryparam value="#cookie.no_client#_#lastid#_#i#" cfsqltype="cf_sql_varchar">
)
</cfquery>
Thanks
Gear_Head wrote
<!---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#" ...>
I think I now understand it a bit more. So you submit a
...Copy link to clipboard
Copied
What happens when you use
<cfset fileCount = Form.PackageFileCount - 1 />
instead?
In any case, it seems weird that you are looping <cffile action="upload">, whereas the form is not being submitted each time. Each upload action requires form submission!
Copy link to clipboard
Copied
Same result and the code for the <cffile action="upload"> was provided by Aurigma with the uploader i added the resize/rename and delete
Copy link to clipboard
Copied
Please dump the Form scope and post its contents here. It will be helpful to see what is actually being posted.
Cheers
Eddie
Copy link to clipboard
Copied
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>
*****************************************************************************
Copy link to clipboard
Copied
Sorry, you misunderstood me. In upload.cfm add the following line:
<cfdump var="#form#">
...and then show us what was dumped after submitting the form with multiple files.
Cheers
Eddie
Copy link to clipboard
Copied
Nothing happens the upload.cfm files only transfeert the images it stays on the index.cfm i uploaded here so you can see
Copy link to clipboard
Copied
Gear_Head wrote
<!---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#" ...>
I think I now understand it a bit more. So you submit a form that has the following fields:
PackageFileCount
SourceName_0
SourceName_1
SourceName_2
SourceName_3
SourceName_4
File0_0
File0_1
File0_2
File0_3
File0_4
Yes? The just dump the form, as EddieLotter suggests, just before the loop.
Copy link to clipboard
Copied
Yes and i did that 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 dump
Copy link to clipboard
Copied
From what I can see, the Aurigma code is Javascript. To ColdFusion, that is just text. If you don't see the dump, then ColdFusion won't see any form.
Copy link to clipboard
Copied
I got it to work i found in Aurigma a field that has the value i was looking for form.PACKAGEINDEX its working now
Copy link to clipboard
Copied
Thanks for sharing. I am glad to hear it's now working.