Reputation: 168
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!
Upvotes: 0
Views: 533
Reputation: 168
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.
Upvotes: 1
Reputation: 20794
I think you are out of luck for a couple of reasons. First, getting a local filepath without the user's express consent isn't going to happen. There are active x controls you can write that do this, but the browser will ask the user if he wants to permit it. Consider that unlikely.
Next, cfftp will only work with machines that are ftp enabled. Most personal computers are not. Those that are might have security measures for you to overcome.
I think the best you can do if the file is too big is to display a message stating so to the user. This message would have information about ftp clients such as Filezilla, and instructions on how to ftp files to the server, assuming of course that the owner of the server will allow the general public to ftp files in.
Upvotes: 0