I’m sorry to post once again, but I am having problems.
When I post from an HTML form, all works fine. But when I post from Servoy, I get a successful upload message. However, the file is not there.
Thanks,
Rachel
var chosenFile = plugins.file.showFileOpenDialog(1);
//the global “gUserFileSeparator” holds either "" for PC or “/” for Mac OS X
var os = application.getOSName();
if(os.indexOf(‘Mac’,1) != -1) {
userFileSeparator = ‘/’;
} else {
userFileSeparator = ‘\’;
}
//set the variable “fName” to the entire path of the document
var filePath = chosenFile.getPath();
var fileName = chosenFile.getName();
plugins.dialogs.showInfoDialog( filePath, fileName, ‘Ok’);
var data = application.readFile(chosenFile);
var localFile = plugins.file.getFileSize(filePath);
if (localFile) {
//Set status area to give some feedback to the user
application.setStatusText(‘Uploading…’);
application.updateUI();
//HTTP post execution
var poster = plugins.http.getPoster(‘http://www.brucel.com/upload.php’);
var didAddFile = poster.addFile(‘userfile’, fileName, filePath);
var httpCode = poster.doPost(); //(httpCode 200 is ok)
if ( httpCode == ‘200’ ) {
plugins.dialogs.showInfoDialog( ‘Web Upload’, ‘Upload successful.’, ‘Ok’);
} else {
plugins.dialogs.showErrorDialog( ‘Web Upload’, 'Upload Error: '+httpCode, ‘Doh!’);
}
//Reset the StatusBar
application.setStatusText(‘’);
} else {
plugins.dialogs.showErrorDialog( ‘Error!’, ‘The selected file doesn't exist.’, ‘OK!’);
}