Copy link to clipboard
Copied
Hi;
I'm trying to upload a large file and perform some resizing on it, but I am getting errors and I don't know why...
here is what happens:
I have a function that uploads, renames & calls for the resizing the file [this is stripped down]
<!--- upload - uploads a file to given directory --->
<cffunction name="upload" access="public" description="uploads a file to given directory" output="no" returntype="any" >
<cfargument name="path" required="no" type="string" default="" />
<cfargument name="mime" required="no" type="string" default="image/jpg,image/gif,image/png" />
<cfif Find("../","#path#") eq 0>
<cftry><cfdirectory action="create" directory="#basepath##path#" /><cfcatch type="any"> </cfcatch></cftry>
</cfif>
<cftry>
<cffile action="upload" destination="#basepath##path#" fileField="file" mode="777" nameConflict="makeunique" />
<cfset error = "false" />
<cfcatch type="any">
<cfset error = "true" />
</cfcatch>
</cftry>
<cfscript>
oldname = cffile.serverFile;
suffix = Right(cffile.serverFile,'4');
prefix = RandomString('15');
bytesize = cffile.fileSize;
newname = prefix&bytesize&suffix;
rename = prefix&bytesize&'-tn'&suffix;
newname=Replace(newname, " ", "", "all");
</cfscript>
<cffile action="rename" source="#basepath##path##cffile.serverFile#" destination="#basepath##path##newname#" />
<cfscript>
resize(newname,newname,'480','640');
resize(newname,rename,'150','200');
</cfscript>
<cfif error is not "false">
<cfreturn error />
</cfif>
</cffunction>
and the resize:
<cffunction name="resize" access="public" description="resize an image to given directory" output="no" returntype="any" >
<cfargument name="name" required="yes" type="string" />
<cfargument name="newname" required="yes" type="string" />
<cfargument name="height" required="no" type="string" default="150" />
<cfargument name="width" required="no" type="string" default="200" />
<cfargument name="path" required="no" type="string" default="" />
<!-- make a copy -->
<cfset copyPrefix = RandomString('5') />
<cffile action="copy" source="#basepath##path##name#" destination="#basepath##path##copyPrefix#_#name#" mode="666" />
<!-- work on the copy -->
<cfimage action="resize" height="#height#" source="#basepath##path##copyPrefix#_#name#" width="#width#" destination="#basepath##path##newname#" overwrite="yes" />
<!-- delete the copy -->
<cffile action="delete" file="#basepath##path##copyPrefix#_#name#" />
</cffunction>
This works fine with files under 2000 pixels wide or so, but when images get above that it will usually resize the first image, but not the second... ?!
in the logs it show a file not found error....
any idea what could be going on? like I said works perfectly for smaller files, but large ones .... not so much.
-sean
Copy link to clipboard
Copied
sean69 wrote:
Hi;
I'm trying to upload a large file and perform some resizing on it, but I am getting errors and I don't know why...
here is what happens:
I have a function that uploads, renames & calls for the resizing the file [this is stripped down]
and the resize:
This works fine with files under 2000 pixels wide or so, but when images get above that it will usually resize the first image, but not the second... ?!
in the logs it show a file not found error....
any idea what could be going on? like I said works perfectly for smaller files, but large ones .... not so much.
-sean
Your code appears to be missing. Can you repost?
--
Adam
Copy link to clipboard
Copied
Can you show the exact error message?
Or, you can play file size limits in CF administrator.
Settings > Request Size Limits