here is the progress i made uploading a file. First the copying of the file to the target directory "webapps". Next the removal of the Directory.
copyremove[cobject_] :=
Module[{temp},
temp = FileNameSplit[cobject[[1]]];
CopyFile[cobject, CloudObject["/webapps/" <> Last[temp]]];
DeleteDirectory[CloudObject[FileNameJoin[Most[temp]]],
DeleteContents -> True];
]
use the function in the clouddeploy to upload a file:
CloudDeploy[
FormFunction[{{"file", "your file please"} -> "UploadedFile"},
( copyremove[#file];
Column[
{"the picture you uploaded"},
{CloudImport["/webapps/" <> Last[FileNameSplit[First[#file]]],
ImageSize -> 100]}
]
) &,
"HTML",
AppearanceRules -> <|
"SubmitLabel" -> "Upload File"|>
],
"test", Permissions -> "Public"]
Note1: the "webapps" folder must exist.
note2: upload something cloudimport is able to read. uploading works for pdf or mp3 but cloudimport will fail.
Okay next step is to limit the files to upload to "sound" in terms of m4a and mp3 files.
This restricts the imput when you push submit. I want to restrict the browse window file extensions.
Restricted["UploadedFile", "MP3"]
I know about this construct in the desktop:
{FileNameSetter[Dynamic[f], "Open", {"Sound" -> {"*.m4a", "*.mp3"}}],
Dynamic[f]}
This does exactly what I need in a webform upload browse window.
Can you help me coding this into the upload webform at the beginning of this post?