File Upload Advice

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

alexmcclune
Ebase User
Posts: 95
Joined: Wed Feb 27, 2013 5:16 pm

File Upload Advice

#1

Postby alexmcclune » Tue Mar 26, 2013 1:11 pm

Hi,

I recently (very recently) attended the Ebase training and I am getting around to using this week. I am looking for some help in regard to file uploads. I am new to ebase and javascript so treat me gently please.

I am hoping "a" user can click a button to upload a file - I found that ebase offers the

Code: Select all

form.uploadFileFromBrowser();
This is a bit long winded but will work. I then discovered you can change the destination directory (for the entire ebase server?) at ufssetup.properties. This is not ideal but for my current testing purposes will work.I am further wondering if it is possible to change:
1) the initial search directory?
2) the initial file type (it always prompts for image files first)?

Thanks.
0 x

LKirby
Ebase User
Posts: 37
Joined: Wed Mar 13, 2013 11:33 am
Contact:

#2

Postby LKirby » Tue Mar 26, 2013 2:45 pm

If you were doing this outside of Ebase you could use something like

Code: Select all

 input type="file" name="file[]" accept="image/*" /> 
And this would let the user only select images in the upload window of their browser. But in Ebase you'll have to change the line in UFSSetup.properties that says:
Ufs.uploadFileTypes=all
to something like:
Ufs.uploadFileTypes: doc,xls,ppt,pdf

This will limit the file types that will be accepted only after the user has clicked upload file. i.e if the user tries to upload an file that doesn't match Ufs.uploadFileTypes then an error message gets displayed.

Sample file upload script if you need it:

// sample upload script
// display the upload page...
form.uploadFileFromBrowser();
// Processing resumes here after the upload..
var fileName = system.variables.$FILE_NAME.value;
if (!fileName)
{
// Error message if the Cancel button has been pressed
event.owner.addErrorMessage("You must upload something");
}
else
{
// Show info message if file uploaded successfully
event.owner.addWarningMessage(1013, [fileName]);
fields.CV_FILE_NAME.value = fileName;
}
// end of upload script

Message 1013 has the text: File && uploaded successfully

Im kinda new to Ebase as well but i've just done the 4 day course which has helped a huge amount.

Luke
0 x

Steve
Moderator
Moderator
Posts: 421
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#3

Postby Steve » Tue Mar 26, 2013 2:45 pm

Hi Alex,

I do not think you can change the initial search directory. I think that this is a browser limitation. I believe the default is the users my documents folder. This maybe because every ones filesystem is different, but they will always have a system home directory.

Which version of Ebase are you running? I believe there is a fix in the latest service pack - 4.4.3. This removes the images from the filter list altogether.

Steve
0 x

alexmcclune
Ebase User
Posts: 95
Joined: Wed Feb 27, 2013 5:16 pm

#4

Postby alexmcclune » Tue Mar 26, 2013 4:21 pm

4.4.2

Yeah I found that sample script - I have the upload working I am just hoping I can configure it. Getting rid of the "images" part is my focus, I will upgrade to 4.4.3 and see if that helps. We have yet to set up our servers yet but we will be using the latest version - I have just installed prematurely.

thanks
0 x

Steve
Moderator
Moderator
Posts: 421
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#5

Postby Steve » Wed Mar 27, 2013 9:21 am

Hi Alex,

You will not be able to configure the dropdown for the file chooser. But you can configure the file types and max file sizes. This was taken from the Working with files documentation:
Two additional parameters of UFSSetup.properties can be used to constrain the uploaded documents:

Ufs.maxUploadFileSize : the maximum permitted file size for an upload. This can be specified as nnnM (megabytes) or nnnK (kilobytes) or just a number e.g. 5M or 500K or 600000 (600K). If omitted the default is 1M. Limiting the size of uploadable files helps prevent denial of service attacks where a hacker attempts to crash the server by uploading extremely large files.

Ufs.uploadFileTypes : contains a comma delimited list of acceptable file types e.g. doc,xls,ppt. Value all can also be specified and this is the default if this parameter is omitted.
The only other stuff you can do is change the working and style the wording. It is fairly basic really.

Steve
0 x


Who is online

Users browsing this forum: No registered users and 17 guests