coldfusion core java instead of cffile -


i using cffile tag in coldfusion 2016 app(website) upload images user server.

i have been ordered stop using cffile , start using underlying java instead because more efficient.

i given code shows how take dir of files , zip them core java. not smart enough use needs.

i need page receive simple post , move file posted specific directory on server. on "action" page of website use:

cffile action="upload" filefield="fieldnamefrompostedform" destination="mydirectoryonserver"   

can point me in direction see under hood of coldfusion can end magic like:

fileoutputstream = createobject("java", "java.io.fileoutputstream");  

in function.

thanks!

progress report:
closer told do. file written server getting error afterwards missing piece of puzzle

<cfscript> function bj_script(source, server_dest_path) { try {      fileoutputstream = createobject("java", "java.io.fileoutputstream");      bufferedoutputstream = createobject("java", "java.io.bufferedoutputstream");      fileinputstream = createobject("java", "java.io.fileinputstream");      bufferedinputstream = createobject("java","java.io.bufferedinputstream");      the_file = createobject("java","java.io.file");      the_file.init(source);      fileinputstream.init(the_file);     bufferedinputstream.init(fileinputstream);      fileoutputstream.init(server_dest_path);      bufferedoutputstream.init(fileoutputstream);       thisbyte = 0;      while (thisbyte neq -1){          thisbyte = bufferedinputstream.read();          if (thisbyte neq -1){              bufferedoutputstream.write(thisbyte);          }      }       fileoutputstream.close();      bufferedoutputstream.close();      return true;  }  catch(any exception) {      return exception;  }  } </cfscript>  <form method="post" enctype="multipart/form-data"> <input type="file" name="test"><br> <input type="submit"><br> </form>  <cfif request_method "post"> <cfset ccc = bj_script(form.test, "c:\inetpub\wwwroot\mywebsite\temp_img\blah.jpg") /> </cfif> 

after image in test uploads error returned of type " java.io.ioexception" message being "stream closed"
must doing while loop incorrectly. can java nerds tell me change?

here's wrote few years ago exact thing coldfusion resultset. should serve decent primer on how connect java class cf , write files.

https://cfprimer.blogspot.com/2009/01/coldfusion-fast-query-to-file-export.html

i have been ordered stop using cffile , start using underlying java instead because more efficient.

it may worth pointing out cffile uses underlying java write file?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -