mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.1 to HEAD
6374: AR-1639 Web Script Content Upload Patch merge: Schema target 71 changed to 101 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6404 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
43
config/alfresco/bootstrap/webscripts/upload.post.js
Normal file
43
config/alfresco/bootstrap/webscripts/upload.post.js
Normal file
@@ -0,0 +1,43 @@
|
||||
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.mimetype = "UTF-8";
|
||||
upload.properties.title = title;
|
||||
upload.properties.description = description;
|
||||
upload.save();
|
||||
|
||||
// setup model for response template
|
||||
model.upload = upload;
|
||||
}
|
Reference in New Issue
Block a user