Uploading files and Images

At the bottom of some admin page are file upload tools. These tools are used to upload different types of files including images and html page-zone files (i.e. html include files). This same tool is also used to upload images on customer pages.

To use the upload tool follow the simple instructions displayed in the pop-up window.

Sections:
Reclication and Image Processing Job
How It Works
Image Processing
Admin Uploads
IIS 6.0 ASP upload limits
Visitor Uploads

Replication and Image Processing Job

Some upload functions initiate file replication and image processing. This job can also be used by other functions.

The SendSafe robot will processing and replicate the contents of the upload directory to a cluster of servers. This replication and processing is accomplished by queuing replication jobs in the robot. One job is queued for each upload. The replication job can also optionally process the image changing it's size, format, etc. For more information on this optional task (see Image Processing).

Server Replication Setup:

Steps performed during replication:

  1. Make sure all locations are accessable
  2. Locate the files in the replication directory - directory is selected based on newest timestamp of files
  3. Preform replication using "Newest Files" as the source

Note: Replication and image processing will not be performed on the following DB table records until the records are released for processing. This is done to insure that dynamic update of records do not occur while they are loaded in a webpage for editing.



Parameter value
param1

This is the "base-relative directory" in which replication will occur. Entry must begin with a '\'.

i.e. Param2+Param1 = Full Path to directory which will be replicated.

param2

This is the list of base directories which will be replicated.

Replication occurs only on the directory. Subdirectories are not included.

param3

This is a comma delimited list of files which will be replicated. File can be identified by either the complete filename (without path) or a Combined Record Locator (CRL).

CRL: If the files contain an option "#" prefix this indicates that the record is not a file name but a combined record locater (CRL) and that the image file needs to be processed as well as replicated. CRL's and non-CRL's cannot be mixed in a job.

The CRL = #<RecordType>!<FieldName>!<RecordPrimaryKey>

The job will access the DB record to get the location and resize information i.e. height x width prefix THEN pre-processing of the files for height and width will be performed.

 


How It Works

The upload system used HTTP POST to upload the file to the webserver. ASP logic is used to collect the uploaded file and save it to the disk on the server.

The basic way the upload works is:

  1. An HTML FORM is displayed into which the user picks a file to upload.
  2. The "contents of this file" + an upload location is POSTED to an ASP file which handles the UPLOAD.
  3. This ASP file will not recieve control until after the POSTING of data (a.k.a. the upload) has completed.
  4. The ASP file allows or disallows the upload based on range checking.
  5. If the uppload is allow, the ASP file will save the uploaded data to the disk as a file.

ASP Popup URL Parameters Param
?dd=xxx This is the basic admin upload used for images. This parameter indicates this is an upload to a subdirectory under EN where dd=<subdirectory>. After the upload the files are synchronized between directories by triggering a replication job (see above). The upload directories are restricted by system config. The first directory in Application("FileUpSubBaseDirectory") is the image upload directory (always).
?ddx=xxx This is the basic admin upload used for spreadsheets. This parameter indicates this is an upload to a subdirectory under EN where ddx=<subdirectory>. After the upload is complete no replication is preformed. The upload directories are restricted by system config. The third directory in Application("FileUpSubBaseDirectory") is the spreadhseet upload directory (always).
?sd=xxx

This is the basic user upload used for custom tools or other image uploads.

This parameter indicates this is an upload to a subdirectory under Application("FTPIMGUploaderServerLogicalBaseDir") where sd=<subdirectory>. After the upload is complete, replication and optional mage processing is preformed on all uploads except where rt=ORDERLINEITEM.

The upload directories are restricted by system config.

The SD=xxx numeric ONLY parameter can be anything but is typically either a CustomerId or SessionID. This value is set by the ASP code which opens the Pop-up
OpenFTPFileUploader('http://....?sd=12345678).

This value is often saved in a cookie so that repeated uploads will be made to the same directory.

Example: http://..../SendSafe.ASPUPDPopUp.asp?sd=512635885.

Application("FTPIMGUploaderServerLogicalBaseDir") = "en/Uploads"
sd=512635885

Complete Upload path = en/Uploads/512635885

?rn1=xxx&rn2=yyy These are the DB record numbers (record locator keys) for the parent record. These keys are:
  • ITEMS => ItemCodeId
  • LISTING => orderLineItemID
  • ADVERTISEMENT => AdIDCode
  • CONTEXTSENSITIVECONTENT => IndexKey
  • ORDERLINEITEM => lineItemID

If this field plus rt and fn are present THEN the filename is set into the field specified by fn. In all case except ORDERLINEITEM, the fb field is replaced. In the case of ORDERLINEITEM the file name without the path is appended to the current contents.

?fn=fieldname This is the name of a field in the primary rb record for the parent record specified by rn1 & rn2. If a parent record and field name are specified then that field name is updated with the file's web site relative location.
?resizeWidth=xxx
&resizeHeight=yyy
Optional parameters which invoke resizing of the images. This parameter must not be used if Image Processing is not enabled.
?rt=xxx This the type of parent record (i.e. the DB column name: item, listing, etc.). The legal values are:
  • ITEMS
  • LISTING
  • ADVERTISEMENT
  • CONTEXTSENSITIVECONTENT
  • ORDERLINEITEM
?cb=xxxyyyzzz

Optional parameters is the callback (cb) URL for the parent. This URL will be loaded into the opener (parent) window if present and upon completion of the file upload and only if DB mods occured (if in DB update mode).

Remember to use the Server.URLEncode( ) function to encode the string or else URL parameters will be lost.

The callback function can be used to load the parent page AND queue a job or other follow up work.

?cbr=xxxyyyzzz

Optional parameters is the callback (cb) URL for the parent PLUS includes the name of the uploaded file in the callback. This URL will be loaded into the opener (parent) window if present and upon completion of the file upload.

Remember to use the Server.URLEncode( ) function to encode the string or else URL parameters will be lost.

The callback function can be used to load the parent page AND queue a job or other follow up work.

The callback URL parameter which contains the relative path + uploaded filename is: &CBFN=

The Advanced config file information for configuring uploads can be found here.

  1. The ASP file which contain the HTML FORM is defined in: Application("FileUpFTPPage"); the default name is: SendSafe.ASPUPDPopUp.asp
  2. This ASP Popup file must include SendSafe.ASPUPDPopUp.inc.asp which contains the POP-Up rendering and range checking logic.
  3. The ASP file to which the FORM is posted is hard coded as "SendSafe.ASPUploader.asp" <= SendSafe.ASPUploader.inc.asp
  4. The JavaScript function OpenFTPFileUploader() is called to open the POP-UP.
  5. Application("FileUploadAllowed") = true
  6. Application("FileUpSubBaseDirectory") contains a list of allowed subdirectories
  7. The PopUp ASP page will recieve the download subdirectory as a URL parameter: "?dd=images"

This is an example of spreadsheet uploading in an admin page:
url = http://localhost/js/SendSafe.ASPUPDPopUp.asp?ddx=/ImportSheets

This is an example of image uploading with record updating and resizing on a customer page:
url = http://localhost/js/SendSafe.ASPUPDPopUp.asp?sd=64900885157117208570454603
&rt=listing
&rn1=167723984
&fn=PictureFileA
&resizeWidth=350
&resizeHeight=350
&cb=http://localhost/js/LE.Step9.asp?LID=167723984

This is an example of image uploading with record updating but without resizing on a customer page:
url = http://localhost/js/SendSafe.ASPUPDPopUp.asp?sd=64900885157117208570454603
&rt=listing
&rn1=167723984
&fn=PictureFileA
&cb=http://localhost/js/LE.Step9.asp?LID=167723984

This is an example of simple file (non-image) uploading on a customer page:
url = http://localhost/js/SendSafe.ASPUPDPopUp.asp?sd=64900885157117208570454603
&cb=http://localhost/js/LE.Step9.asp?LID=167723984

This is an example of simple file (non-image) uploading with record updating of orderlineitem on a customer page:
http://localhost/js/SendSafe.ASPUPDPopUp.asp?sd=12.2563139
&rt=orderlineitem
&rn1=561450459
&fn=ItemParameter
&cb=http://localhost/js/LE.Step9.asp?LID=167723984

 


Admin Upload
This function allows administrators to upload images, spreadsheets, etc.

Keyword Description

Application("FileUploadAllowed") = true

Enabled file upload functions in the Items Admin pages and user pages.

Application("FileUpBaseDirectory") = "C:\Inetpub\IIS\MYWEB\en"

This is the base upload location for admin uploads. This will be used as the base location from param2 of the spreadsheet processing job. This is the base upload location (this is used by Jobs which run and NOT by the ASP upload client). No trailing slashes should be used.

Application("FileUpSubBaseDirectory") = "images,,ImportSheets,AdIMG"

This variable is used by ASP logic to set and range check upload locations. This variable is also used by logic which queues import jobs.

This variable is used to configure upload locations for the ASP tool and for configuration of import job which will be queued. This variable is not used during visitor uploads.

This is a list (array) of upload subdirectory locations where files have been uploaded by the FTP widget. The list is comma delimited.

The first entry in the list is the location where product images have been uploaded.

The second entry in the list is the location where HTML Subcomponent page have been uploaded (typically an empty directory which will result in Application("FileUpWebsiteBaseDirectory") being the target).

The third entry in the list is the spreadsheet import files have been uploaded.

The forth entry in the list is the location where banner advertisement images have been uploaded.

Make sure that the web server and users logged in through the web have both read and write permission to this directory.

Application("FileUploaderReplicationDirs") = "\\ServerA\IISBase\Website_html,\\ServerB\IISBase\Website_html"

This is the base REPLICATION DIR FileUploaderReplicationDirs + FileUpSubBaseDirectory = complete loc. This is a list (array) of base DIR file replication directories. This director PLUS a FileUpSubBaseDirectory will equal a replication location on the hard disk. This location would typlically be the BASE HTML location for a website or a subdirectory within /en/. No trailing slashes should be used. See also: Replication job

Application("FileUpWebsiteBaseDirectory") = "en"

This variable is NOT used by the upload tool. This location must match the Website home directory (this is used ONLY to display suggested entries for the admin pages inside the FTP pop-up window after an upload completes).

Application("FileUpAllowedFileTypes") = "*.jpg,*.gif,*.htm,*.html,*.csv"

This is a list (array) of file extensions which are legal upload types. This entry is comma delimited and be sure to include the (dot).xxx. Warning: Never include executable or server side scripable files of any type.

Application("FileUpFTPPage") = "SendSafe.ASPUPDPopUp.asp"

This is the name of the Pop-up ASP file which contains the upploader code.

 


Visitor Custom Artwork Upload
This function allows the visitor or customer to upload their own artwork for selection in an :IMGLOADERSELECTOR: widget and other uses such as listings.

Setting up HTTP Server:

Operations:

SendSafe GUI setup inside global.inc.asa

SendSafe global.inc.asa file:

Keyword Description
Application("FTPIMGUploaderReplicationDirs") = "\\Server1\c$\base, \\Server2\c$\base"

This is a list of full physcial server directories for which replication will be handled by the SendSafe robot. The individual customer directories will be created under this subdirectory and must match the uploadirectory (Application("FTPIMGUploaderServerLogicalBaseDir"))

The replication latency is typically 60 seconds.

Replication occurs only for the UPLOADED FILES in the specified directory; the entire directory is NOT replicated.

Example:
\\MyServerA\f$\IIS\ProductionWeb\public_html\CEuploads,\\MyServerB\f$\IIS\ProductionWeb\public_html\CEuploads

This example will synchronize UPLOADED FILES in the directories "CEuploads" on both servers.

Set this list to empty to disable replication.

Application("FTPIMGUploaderMyDirName") = "MyArtwork" This is the label that will used for the upload location in the dropdown box use on FFP pages.
Application("FTPIMGUploaderServerLogicalBaseDir") = "uploads"

This is the logical website relative location of the my artwork upload directory on this server.

This location must be within the website directory structure located exactly as named (no virtual directories allowed); THIS is required so that the FFP Web Widget can access the uploaded file.

Within this directory, personal subdirectories for each customer will be created and named by either CustomerId or SessionsId.

Make sure that the web server and users logged in through the web have both read and write permission to this directory.

Example:
Application("FTPIMGUploaderServerLogicalBaseDir") = "en/Uploads"

Application("FTPIMGUploaderAllowedFileTypes") = "*.gif,*.png" This is a list of the allowed file types. Only GIFs and PNGs are supported because the images need to have transparent backgrounds.
Application("FTPIMGUploaderMaxFileSize") = 1000000 This is the maxium file size which can be uploaded (in bytes). Keep this value small to prevent problems of malicious file uploading.
Application("FTPIMGUploaderMaxFileCount") = 10 This is the maxium file count which can be uploaded at a time. Keep this value small to prevent problems of malicious file uploading.

IIS Upload Limits:
IIS has a default limit of 204800 bytes. To increase this limit you must edit the IIS metabase. Follow these steps:

  1. Backup the IIS configuration
  2. Enabled editing of metabase while IIS is running:
    1. Open IIS Manager
    2. Right click on the top IIS node
    3. Select Properties
    4. Check the box "Enable Direct Metabase Edits"
  3. Find the metabase.xml file located in C:\windows\system32\inetsrv and open the file in an ascii text editor.
  4. Find the entry AspMaxRequestEntityAllowed and increase it to 1000000 for 1M or something like that.
  5. If you increase the size beyound 4M you must also find and change AspBufferingLimit which is set by default to 4M
  6. Close the file.
  7. It can take 5 minutes or more for the changes to take effect. To force the changes to take effect immediately, make a small config change in IIS manager, then undo the change, then execute: Open IIS Manager->All Tasks->SAVE CONFIGURATION TO DISK. This forces an update.

 


Image Processing

The SendSafe system can perform backend processing of the uploaded images before they are displayed. This upload process relies on ImageMagick for the processing tasks.

Optional image processing is caused by the presence of resizeWidth and resizeHeight parameters passed into the ASPUpload popup. If a file is to be processed it's display is disabled until processing is complete. These database columns containing images (like PictureFileA,B,C etc. in Listing records) will contain a "#!Width!Height!" prefix in which the '#' indicates the files has been uploaded by the user but has not been image processed yet to the Width and Height specified in the standard "!Width!Height!" format.

The Replication job will contain a CRL in the filename field(s). CRL and non-CRL cannot be mixed. So a replication job cannot contain files which need and do not needed processing.

Configuration and Setup:

KeywordDefault valueExplanation
IMINTEGRATED INSTALL PATH c:\SendSafe\ImageMagick
or
<none>
This keyword enabled and disables Image Magick (IM) Integration by specifing the director into which ImageMagick has been installed. Set this value to "<none>" to disable IM integration.