As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
ProfilePhotoUpload.post.html.ftl: presents that form to the user
<webscript> <shortname>Profile Photo Upload Form Sample</shortname> <description>Form for uploading Photo content and meta-data into Repository</description> <url>/sample/profileupload</url> <authentication>user</authentication> </webscript>
<html> <head> <title>Upload Web Script Sample</title> <link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css"> </head> <body> <table> <tr> <td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td> <td><nobr>Upload Web Script Sample</nobr></td> </tr> <tr><td><td>Alfresco ${server.edition} v${server.version} </table> <p> <table> <form action="${url.service}" method="post" enctype="multipart/form-data" accept-charset="utf-8"> <tr><td>File:</td><td><input type="file" name="file"></td></tr> <tr><td>Title:</td><td><input name="title"></td></tr> <tr><td>Description:</td><td><input name="desc"></td></tr> <tr><td></td></tr> <tr><td><input type="submit" name="submit" value="Upload"></td></tr> </form> </table> </body> </html>
<webscript> <shortname>File Upload Sample</shortname> <description>Upload file content and meta-data into Repository</description> <url>/sample/profileupload</url> <authentication>user</authentication> </webscript>
<html> <head> <title>Upload Web Script Sample</title> <link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css"> </head> <body> <table> <tr> <td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td> <td><nobr>Upload Web Script Sample</nobr></td> </tr> <tr><td>Alfresco ${server.edition} v${server.version}</td></tr> <tr><td></td></tr> <tr><td>Uploaded <a href="${url.serviceContext}/sample/folder${upload.displayPath}">${upload.name}</a> of size ${upload.properties.content.size}.</td></tr> </table> </body> </html>
var filename = null; var content = null; var title = ""; var description = ""; // locate file attributes for each (field in formdata.fields) { if (field.name == "title") { title = field.value; } else if (field.name == "desc") { description = field.value; } else if (field.name == "file" && field.isFile) { filename = field.filename; content = field.content; } } // ensure mandatory file attributes have been located if (filename == undefined || content == undefined) { status.code = 400; status.message = "Uploaded file cannot be located in request"; status.redirect = true; } else { // create document in company home for uploaded file upload = companyhome.createFile("upload" + companyhome.children.length + "_" + filename) ; upload.properties.content.write(content); upload.properties.content.setEncoding("UTF-8"); upload.properties.content.guessMimetype(filename); upload.properties.title = title; upload.properties.description = description; upload.save(); // setup model for response template model.upload = upload; }