MSPGetUploadFile


receive an HTTP upload file

DetailsDetails

  • This provides a useful utility function for uploading files from the client to the server using multipart/form-data submissions.
  • The contents of the file are saved in a new file on the server, and the name of this file is returned.
  • The file on the server will eventually be cleared in a way similar to the clearing of image and other temporary files.
  • The result of MSPGetUploadFile is a list of rules that show the filename on the server, the original filename on the client, and the content type.
  • "FileName"the name of the file on the server
    "OriginalFileName"the original name of the file before upload
    "ContentType"the content type of the file
  • Note that parameters that are present in the HTTP headers become available as $$ variables after the use of MSPGetUploadFile or MSPGetUploadFileList. After this they can be used in the normal way.

    There is a maximum size for a file that can be uploaded by MSPGetUploadFile; by default this is 4MB. This is set by the configuration parameter FileUploadSizeLimit.

  • The following exception can be thrown by MSPGetUploadFile.
  • MSPException["FileUploadError"]if an error is encountered while retrieving the upload file

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

The function cannot be demonstrated since it must really be part of an actual HTTP transaction with appropriate information sent from the client. This example just simulates the way that the function can be used with Mathematica programming.

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

The filename can be extracted with the typical Mathematica commands used for working with rules.

In[3]:=
Click for copyable input
Out[3]=