We help IT Professionals succeed at work.

cffile upload question

i have a cffileupload which do the uploads successfully, now my concern is i want to add few extra fields to it,

Based on the above, i have come up with an idea that store the uploaded images to the virtual RAM and then clicking on the Submit button which i have defined the Extra fields like watermarking,, blurring, posturing erc, should do on the images stored on the virtual ram and then each processing of an image store the relevant images to its corrosponding folder

is the way i am doing is OK, if yes, Please guide me how do i proceed furthur as an sample application

Watch Question

Pravin AsarPrincipal Systems Engineer
Top Expert 2005

First of all, cffileupload  post the form contents with actionscript post. It will not pickup the other form variables.

Looking at problem statement, looks like following workflow might by good

1. Load the file to temp storage area.
2. After loading , take user to display the latest files.
3. For each uploaded file, ask user what actions he expects you to do (such as watermarking,, blurring, posturing etc).
4. When form  is submitted do the requisite action for each file and save to final destination.

This may give you, option to perform, different set of actions with each image file.
so u are saying is

1. do the cffileupload first in the temp right

2. then create a new page to create the watermarking stuff or something like this and then it actually process them right

like splitting them in 2/3 different pages to make the process easier to flow

any sample?
u did not answered yet
Principal Systems Engineer
Top Expert 2005
Well this is bit of work to give you all of the functional code.

Any way see the attached code. This is basically 4 files ...please split the code snippet into appropriate files.

You can add your own image_processing code..


<cfform name="f1"  method="post" action="processfiles_action.cfm">
	<table cellpadding="20" cellspacing="20" width="800">
				<cffileupload url="uploadfile_action.cfm" width="750" height="600"  maxuploadsize="500" bgcolor="##d7c19f"/>
			<th style="text-align:right;">
				<cfinput type="submit" name="submit" value="NEXT=>" /> 

<!--- FILE: uploadfile_action.cfm --->

<cffile action="uploadall" destination="#expandPath('./myuploads')#" nameconflict="overwrite" />

<CFSET BASE_DIR = "#expandPath('./myuploads')#">

<cfset qexport=QueryNew("SeqNo,FileName,FilePath,Type,Size,LastModified","Integer,VarChar,VarChar,VarChar,Integer,Date")/>
<cfset seqNo=1>
<cfloop query="mydirectory"> 
<cfif #CompareNoCase(trim(mydirectory.type),"DIR")#>
<cfset tt=QueryAddRow(qexport)/>
<cfset  mypath=#mydirectory.directory# & #DIRECTORY_SEPARATOR#>
<cfset  myname=#mydirectory.name#>
<cfset tt=QuerySetCell(qexport,"SeqNo",#seqNo#)>
<cfset tt=QuerySetCell(qexport,"FilePath",mypath)>
<cfset tt=QuerySetCell(qexport,"FileName",myname)>
<cfset tt=QuerySetCell(qexport,"Size",#mydirectory.size#)>
<cfset tt=QuerySetCell(qexport,"Type",#mydirectory.type#)>
<cfset tt=QuerySetCell(qexport,"LastModified",#mydirectory.dateLastModified#)>
<cfset seqNo= seqNo+1>

<cfform name="pro_files" action="image_process.cfm" method="post">
<table cellspacing=1 cellpadding=10> 
<cfoutput query="qexport"> 
    <td><cfinput name="filename_#seqno#" type="hidden" value="#qexport.FileName#">#qexport.FilePath##qexport.FileName#</td> 
    <td>#DateFormat(qexport.LastModified,"MM/DD/YYYY")# #TimeFormat(qexport.LastModified,"HH:MM:SS")#</td> 
		<cfinput type="checkbox" name="process_img_#seqno#" value="watermark">WaterMark
		<cfinput type="checkbox" name="process_img_#seqno#" value="blur">Blur
	<td colspan="5">
		<cfinput name="reset" value="Reset" type="reset" >
		<cfinput name="submit" value="Process" type="submit" >

<cfdump var="#form#"/>

Open in new window

Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Thanks But i have a question here, i been to split the cffileupload to work, currently moving all the images to the temp folder, now the issue is

i want to move all the files to fullimages folder which i am doing through the cffilke move tag, upon moving, i think i have to loop over all the images one by one so that it can run everytime and create the respective watermark or blur everytime it needed.

But i am confused, will not this process consume too much resources, because if i upload 100 files in cffileupload in temp directory and then i am moving all those files to fullimages folder and then looping over them to actually store to their respective folders and also do the resizing, postering, scaling at the same time

and save in DB too
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

For a multiuser scenerio, best option

1.create a unique temp directory (may be use timestamp as part of name). this is where users files will be uploaded.
2. Get the listing of files from the unique temp directory.
3. Ask Processing Options
4. Process the files
5. The processed files will be saved at desired location.
5. After processing clean-up the unique temp directory
6. Delete the unique temp directory

what scenario asked is that the best option of not, because still i have to loop over each single image and finish its processing and move again
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Is that the approach you have to take, considering cffileupload does update the file differently than the conventional form  post/submit action.

If you uploads 100 files, you have no option but to process these 100 files.


well not sure, but how can i make use of cfthread tag inside or outside the loop to make the processing faster enough for this type i am going ahead
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

You have other options (such as batch at a specified time).

Once cfthread is created, you will running multiple instances of thread (as forked by loop).

look at this post


let me work out on this, i will write some kind code and share here