I am using a shared hosting server that limits the filesize (let’s say 100 MB) for CFFILE Action=”Upload” – my code works for 99% of all uploads, but on files that are larger than 100 MB, they recommend that I use FTP.
In order for CFFTP to work, I need the local pathname (i.e. “c:\myFiles\fileToUpload.mpg”), but because I’m using the CFFORM ENCYTYPE=”multipart/form-data” if I dump the formfield, it is listed as a .tmp on the server. If I eliminate the ENCTYPE designation, then I get the local pathname, and I’m good to go.
My goal is to switch to CFFTP if the filesize exceeds 100 MB seamlessly. Is it possible to extract the local pathname when the ENCTYPE is set to “multipart/form-data” ?
OR is there some other way to allow CFFTP and CFFILE to work in this way?
Here’s an abstraction of how I’d like to see things work:
<!--- perform actions --->
<cfif isdefined("FORM.fileToUpload")>
<cfif fileSizeInMB(FORM.fileToUpload) < 100>
<cffile action="upload" blah blah>
<cfelse>
<cfftp action="putfile" blah blah>
</cfif>
</cfif>
<!--- show page --->
<cfform action="#CGI.SCRIPT_NAME#" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" />
<input type="submit" />
</cfform>
Any help is greatly appreciated!
According to the ColdFusion documentation, the CFFTP tag is used to “… move files between a ColdFusion server and an FTP server.” – this tag does not allow you to read from a client’s hard drive to upload to the server. The only way to transfer files from the client is with CFFILE.
In my situation, I will have to let the client know that there is now a restriction on the size of files to upload – per Dan’s suggestion, I will recommend the use of Firezilla to upload all files over 100 MB.
Thanks to all for your responses.