I have a FormFunction that should work only with CSV files, something like:

CloudDeploy[FormFunction[{"file" -> "CSV"}, Dimensions[#file] & ], 
 Permissions -> "Public"]

How can I create a restriction so only CSV files can be submitted?

enter image description here

I want to show a message saying "only CSV files can be uploaded" when someone tries to load an image, and prevent the submit.

I tried this, didn't work:

 FormFunction[{"file" -> <|"Interpreter" -> Restricted["CSV"]|>}, 
  Dimensions[#file] & ], Permissions -> "Public"] 

1 Answer 1


Instead of having FormFunction directly convert CSV input into a table of values, upload the CSV file to a CloudObject and do the CSV import in the cloud:

   FormFunction[{"x" -> Interpreter[Restricted["UploadedFile", "CSV"]]},
      Dimensions[Import[#x, "CSV"]] & ], 
   FileNameJoin[{$CloudRootDirectory, "CSVRestrictedUploadedFile"}],
   Permissions -> "Public" ]

An attempt to submit a file other than type CSV will fail and generate an “Enter a file of type CSV” alert under the error condition input field:

Enter CSV file

See documentation "UploadedFile" (interpreter type).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.