How to transfer file from php to java using php-java-bridge -


i trying upload file, front end application in php , backend engine in java. both communicate through php-java_bridge.

my first action was, when file posted php page, retrieve content.

$filedata= file_get_contents($tmpuploadedlocation); 

and pass information java ejb façade accepts byte array savefilecontents(byte[] contents)

here how in php converted $filedata byte array.

$bytearraydata = unpack("c*",$filedata); 

and called java service (java service object retrieved using php-java-bridge)

$javaservice->savefilecontents($bytearraydata); 

this works fine if file size less, if size increase 2.9 mb, receive error , hence file contents not saved on disk.

fatal error: allowed memory size of 134217728 bytes exhausted //this php side error due unpack 

i not sure how this, above method not accurate, please have few limits.

  1. the engine(java) responsible saving , retrieving contents.
  2. php-html front end application, thing php
  3. php communicate java using php-java-bridge
  4. ejb's methods accessed php saving , retrieving information.

everything working fine above combination, upload , saving documents. ejb (application engine access point) used front-end application (php or java application through remote interface (lookups)).

my question how file contents php can sent java, not break thing (memory)?

instead of converting file array i'd try pass string. encode string base64 in php , decode array in java.

another option pass file thru filesystem. linux systems have /dev/shm or /run/shm mounted tmpfs, way pass temporary data between programs without incurring hard-drive overhead. typical tmpfs algorithm 1) create folder; 2) remove old files (e.g. files older minute); 3) save new file; 4) pass file path java; 5) remove file. step 2 important in order not waste ram if steps 3-5 not completed reason.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -