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

Thanks
Comment
Watch Question

Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
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
Commented:
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..


<!--- FILE: FILEUPLOAD.CFM --->

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

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

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


<!--- FILE: PROCESSFILES_ACTION.CFM --->
<CFSET BASE_DIR = "#expandPath('./myuploads')#">
<CFSET DIRECTORY_SEPARATOR = "\">
<CFPARAM NAME="SUBDIR" DEFAULT="">
<CFDIRECTORY ACTION="LIST" RECURSE="true"  DIRECTORY="#BASE_DIR##DIRECTORY_SEPARATOR##SUBDIR#" NAME="mydirectory" SORT="TYPE,NAME">

<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>
<cfelse>
</cfif>
</cfloop>

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

<!--- FILE: IMAGE_PROCESS.CFM --->
<cfdump var="#form#"/>

Open in new window

Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
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

Commented:
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

Commented:
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.

Thanks,


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

Commented:
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

http://www.bennadel.com/blog/1859-Executing-A-Recursive-CFThread-In-ColdFusion-9.htm


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