capture file size and other file information using php

I am new to scriptcase and would like to use php filesize() and other file attributes on files I upload. How can I embed php calls in the onbeforeinsert so I can assign these values to fields?

Your help is appreciated.

Is there a getting started document on programming within scriptcase?

There are mainly videos. Here on the website of scriptcase and a few on our’s (5 minutes for novice). For file upload you don’t have to do anything with filesizes except configuring max filesize and filetypes for uploading. Don’t do too much, use the strength of SC. Only create php for businessrules and stuff which is not by default supported by SC.

Thanks for the info on the videos. My other questions was, I want to capture the file size of the uploaded file, is there a way to do that from within sc?

Rob

Since you have the path of the uploaded file all you need to do is to use the filesize(filename) function

How do I reference the filename, if the drag and drop area is used? Is there a variable that the full path and file name is captured?

It should be putting the name(s) in a field in the database.

Yes, the filename is stored in the db - but not full path in which the file lives. Is there a way to get the filesize out of the db blob field?

Ok - It’s in 2 places.

The main path for file uploads is in the form’s Application | Settings section (Documents Path):

However, if you also select the field that is used to upload files, you will also see a place where you can specify a subfolder (Subfolder).

Concatenating them together gives you full file path. Of course if you leave the second part blank then you only need the first part (i.e. the main path).

Re filesize from DB - not sure - but easy to get use php filesize() on the document in the above path to get that information.

int filesize ( string $filename )

$filename is full path to the file

path.JPG

sf.JPG

with

$Size=filesize($this->SC_IMG_FieldName)

you can take the size in bits… it works!!!