I have created a file system that allows for users to upload files into media fields on the database. It works fine on the local PC. However, over a remote connection the file is not getting uploaded, or is being corrupted. Can anybody see where it’s going wrong. The code is below.
Do I need some form of progress bar to show the file being uploaded, and confirm the upload before moving on in the script?
If so, can somebody advise on how I do this?
Many thanks in advance.
MerMer
controller.newRecord(true)//new record at top of list
//get the full path to file that needs to be uploaded
var windowsFilePath = application.showFileOpenDialog();
application.output(windowsFilePath);if (windowsFilePath)//for cancel
{
var normalizedFilePath = “”;
//turns file path into UNIX variant rather than windows.
normalizedFilePath = utils.stringReplace(windowsFilePath,‘\’,‘/’)//make windows path like unix path
application.output(normalizedFilePath);
// saves file into attachment media field.
attachment = application.readFile(normalizedFilePath);
// gets the file size and saves this into the filesize field.
filesize = plugins.file.getFileSize(normalizedFilePath);
var idx = normalizedFilePath.lastIndexOf(“/”);
application.output (idx);
if (idx != -1)
{
normalizedFileName = normalizedFilePath.substring(idx+1);
application.output (normalizedFileName);
}
filename = normalizedFileName;}
// puts the USER NAME in the source field
source = security.getUserName();//show input dialog ,returns nothing when canceled
var typedInput = plugins.dialogs.showInputDialog(‘Description’,‘Enter a description of the file’);
filedescription = typedInputcontroller.saveData()
//remind the user to enter a company name.
//show dialog
var thePressedButton = plugins.dialogs.showInfoDialog(‘Company?’, ‘Enter any associated company from the company field’,‘OK’);
application.output (thePressedButton);//sets cursor into the company field
elements.companyid.requestFocus(true);