|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.acesoft.aceoffix.FileRequestPHP
public class FileRequestPHP
FileRequestPHP class is used to receive and save the document submitted by AceoffixCtrl with PHP code.
FileRequestPHP class is used to receive and save the document submitted by AceoffixCtrl with PHP code. FileRequest object must be created and used in the page assigned by AceoffixCtrl.SaveFilePage.
Constructor Summary | |
---|---|
FileRequestPHP()
Initializes a new instance of the FileRequest class. |
Method Summary | |
---|---|
java.lang.String |
close()
Returns a success message to AceoffixCtrl. |
java.lang.String |
getDocumentText()
Gets the plain text of the document without any format. |
byte[] |
getFileBytes()
Returns an array of the bytes in the file submitted by AceoffixCtrl. |
java.lang.String |
getFileExtName()
Gets the file name extension of the file. |
java.lang.String |
getFileName()
Gets the file name of the file submitted by AceoffixCtrl. |
int |
getFileSize()
Gets the size of the file, in bytes. |
java.io.FileInputStream |
getFileStream()
Returns an FileInputStream object which contains the file bytes submitted by AceoffixCtrl. |
java.lang.String |
getFormField(java.lang.String name)
Gets the value with the specified name in the form fields of the page with AceoffixCtrl. |
java.lang.String |
getLocalFileExtName()
Gets the file name extension of the client's local file submitted by AceoffixCtrl. |
java.lang.String |
getLocalFileName()
Gets the file name of the client's local file submitted by the AceoffixCtrl. |
void |
load(java.lang.String Input)
Load the request stream with PHP code. |
void |
saveToFile(java.lang.String saveAsFileName)
Saves current document to the folder of server disk. |
void |
setCustomSaveResult(java.lang.String value)
Sets the custom saving result defined by developer. |
void |
showPage(int width,
int height)
Prompts a custom dialog box to show the saving result. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileRequestPHP()
Method Detail |
---|
public java.lang.String getFileName()
Typically, it's the file name which is opened. The file name contains the file name extension, but not including the directory path. If the document which is going to be opened is a binary stream outputted by server page, the file name will be "aceoffix" with the correct file name extension.
FileRequestPHP.saveToFile() to learn how to save document.
public java.lang.String getFileExtName()
FileRequestPHP.saveToFile() to learn how to save document.
public java.lang.String getLocalFileName()
This file name contains the file name extension, but not containing the folder path. When AceoffixCtrl is used to view the Office file uploaded from local client, this property can get the name of the local file.
public java.lang.String getLocalFileExtName()
public int getFileSize()
FileRequestPHP.saveToFile() to learn how to save document.
public void setCustomSaveResult(java.lang.String value)
The following example shows how to use the CustomSaveResult property.
$ip = GetHostByName($_SERVER['SERVER_NAME']); require_once("http://".$ip.":8080/JavaBridge/java/Java.inc"); $freq = new Java("com.acesoft.aceoffix.FileRequestPHP"); $freq->load(file_get_contents("php://input")); $filepath=realpath(dirname($_SERVER["SCRIPT_FILENAME"])); $freq->saveToFile($filepath."\\doc\\".$freq->getFileName()); freq->setCustomSaveResult("My custom result."); echo $freq->close();
Then, custom saving result can be got from the CustomSaveResult property of AceoffixCtrl with JavaScript.
<script language="javascript" type="text/javascript"> function SaveDocument() { document.getElementById("AceoffixCtrl1").SaveDocument(); alert(document.getElementById("AceoffixCtrl1").CustomSaveResult);//You can determine the next code logic according to the value of CustomSaveResult. } </script>
public void load(java.lang.String Input) throws java.lang.Exception, java.io.IOException
java.lang.Exception
java.io.IOException
public java.lang.String close() throws java.io.IOException, java.lang.Exception
If the code for saving document executes successfully, you should call this method to return a success message to AceoffixCtrl. Typically, the close method should be called at the end of code in SaveFilePage.
java.io.IOException
java.lang.Exception
FileRequestPHP.saveToFile() to learn how to save document with PHP code.
public void saveToFile(java.lang.String saveAsFileName) throws ServletException, java.io.IOException, java.lang.Exception
Saves current document to assigned server folder. If you want to save the document to database field, please call the getFileBytes() or getFileStream() method. Note: The maximum size allowed for a request, which includes uploaded files, is 4 MB, by default. If the uploaded file is larger than its maximum size, errors may occur there.
The following code example demonstrates how to save the document that are uploaded by AceoffixCtrl to the specified folder on the Web server's disk.
In order to display all the possible exception messages when you debug your code, do not use try...catch statements in SaveFilePage. When an exception is thrown, AceoffixCtrl will show the exception dialog box.
$ip = GetHostByName($_SERVER['SERVER_NAME']); require_once("http://".$ip.":8080/JavaBridge/java/Java.inc"); $freq = new Java("com.acesoft.aceoffix.FileRequestPHP"); $freq->load(file_get_contents("php://input")); $strFileName = freq->getFileName(); $strFileExtName = freq->getFileExtName(); $iFileSize = freq->getFileSize(); // The current document can be saved to the folder on server. $filepath=realpath(dirname($_SERVER["SCRIPT_FILENAME"])); $freq->saveToFile($filepath."\\doc\\".$freq->getFileName()); echo $freq->close();
saveAsFileName
- To save document to target location, absolute path and file name must be specified. To save document to the folder within website, you may use getRealPath() to get the absolute path.
ServletException
java.io.IOException
java.lang.Exception
public void showPage(int width, int height) throws java.io.IOException
After save document, if you want to prompt a custom dialog box to show the saving result, you can call this method. The message page shown in the dialog box is the current SaveFilePage. By default, the SaveFilePage will display nothing. You can add friendly messages in the PHP of SaveFilePage.
The following code example shows how to use the ShowPage method to let AceoffixCtrl display a custom error dialog box to user.
$ip = GetHostByName($_SERVER['SERVER_NAME']); require_once("http://".$ip.":8080/JavaBridge/java/Java.inc"); $freq = new Java("com.acesoft.aceoffix.FileRequestPHP"); $freq->load(file_get_contents("php://input")); $filepath=realpath(dirname($_SERVER["SCRIPT_FILENAME"])); $type = $freq->getFileExtName(); if((strcasecmp(".doc", $type) == 0)||(strcasecmp(".docx", $type) == 0)){ // Only save the Word documents. $freq->saveToFile($filepath."\\doc\\".$freq->getFileName()); } else{ echo "Failed to save. The current document is not a Word document."; // This is a simple error message, you can add friendly message to the current page. $freq->showPage(380, 200); // If the document is not a Word document, AceoffixCtrl will open a modal dialog to show the custom error page. } echo $freq->close();
width
- The width of custom dialog, in pixels.height
- The height of custom dialog, in pixels.
java.io.IOException
public byte[] getFileBytes() throws ServletException, java.io.IOException, java.lang.Exception
If you want to save the file to the data field of a database, you should call this FileBytes property. If you want to save the file to disk, you only need to call FileRequest.saveToFile().
ServletException
java.io.IOException
java.lang.Exception
public java.io.FileInputStream getFileStream() throws ServletException, java.io.IOException, java.lang.Exception
ServletException
java.io.IOException
java.lang.Exception
public java.lang.String getDocumentText() throws java.io.IOException, java.lang.Exception
Note: This property only applies to Word currently.
The following code example shows how to use the DocumentText property to get the plain text of the document.
$ip = GetHostByName($_SERVER['SERVER_NAME']); require_once("http://".$ip.":8080/JavaBridge/java/Java.inc"); $freq = new Java("com.acesoft.aceoffix.FileRequestPHP"); $freq->load(file_get_contents("php://input")); $strDocumentText = freq->getDocumentText(); // After you get the text content, you can save it to the database. $filepath=realpath(dirname($_SERVER["SCRIPT_FILENAME"])); $freq->saveToFile($filepath."\\doc\\".$freq->getFileName()); echo $freq->close();
java.io.IOException
java.lang.Exception
public java.lang.String getFormField(java.lang.String name) throws java.io.IOException, java.lang.Exception
When AceoffixCtrl is saving document, you can call this method to get the values of form fields posted from the page with AceoffixCtrl.
Note: To be able to capture the value, the form field must have a name attribute.
The Form field can be Input Box, Drop-down Box, Radio, Check Box, TextArea, Hidden Field etc..
The following code example shows how to use the GetFormField method to get the value of the form field posted from the page with AceoffixCtrl.
$ip = GetHostByName($_SERVER['SERVER_NAME']); require_once("http://".$ip.":8080/JavaBridge/java/Java.inc"); $freq = new Java("com.acesoft.aceoffix.FileRequestPHP"); $freq->load(file_get_contents("php://input")); $strSubject = freq.getFormField("EditSubject"); // After you get the input text, you can save it to the database. $filepath=realpath(dirname($_SERVER["SCRIPT_FILENAME"])); $freq->saveToFile($filepath."\\doc\\".$freq->getFileName()); echo $freq->close();
name
- The name of form field in the page.
java.io.IOException
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |