Encontre un plugin para escanear desde un navegador web a traves de twain, pero el problema es que no se nada de JAVA y no se como tratar la información con PHP, viendo parte del codigo miro que hace una conexión POST pero no se cual es nombre de la variable para tratarla con $_POST['nombre de la variable de la applet java'], de antemano muchas gracias.
Este es parte del codigo, por cierto la applet java ya viene compilada este código lo saque decompilando el .jar con Java Decompiler
Código Java:
Ver originalImage image
= MorenaStudio.
MainPanel.
this.
selected.
getImage(); int imageHeight = image.getHeight(null);
int imageWidth = image.getHeight(null);
int sliceHeight = 512;
int sliceCount = imageHeight / sliceHeight;
if (imageHeight % sliceHeight > 0) {
sliceCount++;
}
int sliceNum = 0;
int thisSliceHeight = sliceHeight;
String finalImageServerPath
= ""; for (int sliceTop = 0; sliceTop < imageHeight; sliceTop += sliceHeight)
{
if (imageHeight - sliceTop < sliceHeight) {
thisSliceHeight = imageHeight - sliceTop;
} else {
thisSliceHeight = sliceHeight;
}
sliceNum++;
System.
out.
println("Slice " + sliceNum
+ " of " + sliceCount
); MorenaStudio.MainPanel.this.status.setText("Sending image to server...");
bufferedImage.createGraphics().drawImage(image, 0, 0 - sliceTop, null);
System.
out.
println("Allocated bufferedImage,Total:," + Math.
round((float)(Runtime.
getRuntime().
totalMemory() / 1024L
)) + ",Max:," + Math.
round((float)(Runtime.
getRuntime().
maxMemory() / 1024L
)) + ",Free:," + Math.
round((float)(Runtime.
getRuntime().
freeMemory() / 1024L
)));
tmp.deleteOnExit();
ImageIO.write(bufferedImage, "jpg", tmp);
System.
out.
println("Wrote JPG to temp file,Total:," + Math.
round((float)(Runtime.
getRuntime().
totalMemory() / 1024L
)) + ",Max:," + Math.
round((float)(Runtime.
getRuntime().
maxMemory() / 1024L
)) + ",Free:," + Math.
round((float)(Runtime.
getRuntime().
freeMemory() / 1024L
))); if (MorenaStudio.MainPanel.this.documentBase != null) {
uploadURL
= new URL(MorenaStudio.
MainPanel.
this.
documentBase,
"upload.php?slice_index=" + sliceNum
+ "&slice_total=" + sliceCount
+ "&uid=" + MorenaStudio.
MainPanel.
this.
userId + "&auth=" + MorenaStudio.
MainPanel.
this.
userAuth + "&twain_source=" + URLEncoder.
encode(MorenaStudio.
MainPanel.
this.
twainSourceName,
"UTF-8")); } else {
uploadURL
= new URL("http://scanandupload.com/upload.php?slice_index=" + sliceNum
+ "&slice_total=" + sliceCount
+ "&uid=" + MorenaStudio.
MainPanel.
this.
userId + "&auth=" + MorenaStudio.
MainPanel.
this.
userAuth + "&twain_source=" + URLEncoder.
encode(MorenaStudio.
MainPanel.
this.
twainSourceName,
"UTF-8")); }
System.
out.
println("documentBase:" + MorenaStudio.
MainPanel.
this.
documentBase); System.
out.
println("Uploading to: " + uploadURL
);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setDefaultUseCaches(false);
connection.setRequestProperty("content-type", "img/jpeg");
connection.setRequestProperty("twain-source", MorenaStudio.MainPanel.this.twainSourceName);
connection.setRequestProperty("slice-total", sliceCount);
connection.setRequestProperty("slice-index", sliceNum);
byte[] buffer = new byte[4096];
int bytes_read;
while ((bytes_read = is.read(buffer)) != -1)
{
int bytes_read;
out.write(buffer, 0, bytes_read);
}
out.close();
int c;
while ((c = in.read()) != -1)
{
int c;
}
in.close();
System.
out.
println("Uploaded File,Total:," + Math.
round((float)(Runtime.
getRuntime().
totalMemory() / 1024L
)) + ",Max:," + Math.
round((float)(Runtime.
getRuntime().
maxMemory() / 1024L
)) + ",Free:," + Math.
round((float)(Runtime.
getRuntime().
freeMemory() / 1024L
)));
finalImageServerPath = connection.getHeaderField("scan-img-path");
}
if (!MorenaStudio.MainPanel.this.inAppletViewer)
{
URL nextURL
= new URL("javascript:onScanFinished(\"" + finalImageServerPath
+ "\")"); if (MorenaStudio.MainPanel.this.appletContext != null) {
MorenaStudio.MainPanel.this.appletContext.showDocument(nextURL);
} else {
System.
out.
print("No applet context so didn't forward the browser."); }
}
System.
out.
println("Uploaded file to " + finalImageServerPath
); MorenaStudio.MainPanel.this.status.setText("Scan is uploaded.")