CFLib.org – Common Function Library Project

getUploadData()

Last updated June 23, 2010

author

David Boyer

Version: 0 | Requires: CF8 | Library: UtilityLib

Description:
Without touching "cffile action='upload'" this function can give you all the information you need about any uploads. This includes the size, original name, temporary name, content type and extension.

Return Values:
Returns a struct.

Example:

<cfdump var="#getUploadData()#" />

Parameters:

No arguments.

Full UDF Source:

/**
 * Returns a structure containing upload information.
 * 
 * @return Returns a struct. 
 * @author David Boyer (dave@yougeezer.co.uk) 
 * @version 0, June 23, 2010 
 */
function getUploadData() {
  var local = {};
  local.result = {};
  if (cgi.request_method Eq 'post') {
    local.uploads = form.getPartsArray();
    if (StructKeyExists(local, 'uploads')) {
      local.count = ArrayLen(local.uploads);
      for (local.u = 1; local.u Lte local.count; local.u++) {
        local.info = GetFileInfo(form[local.uploads[local.u].getName()]);
        local.result[local.uploads[local.u].getName()] = {
          tempFileName = form[local.uploads[local.u].getName()],
          originalName = local.uploads[local.u].getFileName(),
          contentType = local.uploads[local.u].getContentType(),
          filesize = local.info.size,
          ext = ListLast(local.uploads[local.u].getFileName(), '.')
        };
      }
    }
  }
  return local.result;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson