Dec 17, 2015; 08:12
Jolle Carlestam
Update to jc_fileuploads
I have made a minor update to my gist type jc_fileuploads.
There was a rare bug in the method jc_fileuploads -> suffix. When called for a file that does not have a suffix it returned the entire file name.
The method now uses -> splitextension instead. Safer and faster than previous method.
You can find the type here:
https://gist.github.com/jolle-c/9957187
If you’ve not looked into jc_fileuploads before, now is a good time. It is by far the most convenient way of dealing with uploaded files. Here are the examples on how to use it:
local(myfile = jc_fileuploads(1)) // the integer is optional and will if provided restrict the method to the n:th count of uploaded files
#myfile -> size // how many files that where uploaded or handled by the type
#myfile -> contenttype // or #myfile -> contenttype(n) when targeting the n:th file // for example image/jpeg
#myfile -> fieldname // #myfile -> fieldname(n)
#myfile -> filesize // #myfile -> filesize(n)
#myfile -> filename // #myfile -> filename(n)
#myfile -> tmpfilename // #myfile -> tmpfilename(n)
#myfile -> suffix // #myfile -> suffix(n)
#myfile -> save('/path/to/file/filename.sfx')
or
#myfile -> save('/path/to/file/filename.sfx', -overwrite, -count = n)
An actual file can also be retrieved as a file object from jc_fileuploads using
#myfile -> file
or
#myfile -> file(n)
Short hand examples
jc_fileuploads -> file // will return the uploaded file as a file object
jc_fileuploads -> save('/path/to/file/filename.sfx’)
jc_fileuploads also works with query expressions
local(myfiles = jc_fileuploads)
(with file in #myfiles
let name = #file -> filename
let filesize = #file -> filesize
select 'The file ' + #name + ' was uploaded with size ' + #filesize) -> join('<br />’)
Enjoy
HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>