cancel
Showing results for 
Search instead for 
Did you mean: 

webscript uploading exception

mialfresco
Champ in-the-making
Champ in-the-making
Hi i'm trying to upload a file using simple webscripts followed @  http://wiki.alfresco.com/wiki/Web_Scripts_Examples#Folder_Browse.2FRSS_Feed…

every thing working fine. Now i want to integrate this script with a sample application.
Here my functionality is, there is  a link for uploading a file. when the user clicks on this it will display a popup box with browse,title,description options. And after clicking on this i'm getting the following exception.
404 Description:    Requested resource is not available. Message:   Script url /simpleui/document/$action="/alfresco/service/simpleui/document/upload does not map to a Web Script.    Exception:   org.alfresco.web.scripts.WebScriptException - Script url /simpleui/document/$action="/alfresco/service/simpleui/document/upload does not map to a Web Script.       org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:106)   org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)   org.apache.catalina.core.‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


here my code is, DocumentList.get.html.ftl
var dlg,previewdlg,removedlg,sdlg,udlg;      function init(e) {         dlg        = dojo.widget.byId("DialogContent");         previewdlg = dojo.widget.byId("DialogPreview");         removedlg  = dojo.widget.byId("DialogRemove");         sdlg        = dojo.widget.byId("SpaceDialog");         udlg        = dojo.widget.byId("UploadDialog");      }      function uploadFile() {         document.getElementById("upload_label").innerHTML='Upload a File';         document.forms['upload_new'].action = '$action="${url.serviceContext}/simpleui/document/upload';         udlg.show();      }Upload a file   <img src="${url.context}/images/icons/add.gif" onClick="uploadFile();"/></b>   </tr><div dojoType="dialog" id="UploadDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"><form name="upload_new" action="" method="post">   <table>   <tbody>      <tr>         <th colspan="2"><b><div id="upload_label"></div></b></th>      </tr>          <tr><td>File:<td><input type="file" name="file">          <tr><td>Title:<td><input name="title">          <tr><td>Description:<td><input name="desc">          <tr><td><td>          <tr>         <td colspan="2" align="center">                        <input type="submit" name="submit" value="Upload">            <input type="button" id="hider2" value="Cancel" onClick="udlg.hide()"></td>         </tr>   </tbody>    </table> </form>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


and my upload.post.desc.xml is
<webscript>  <shortname>File Upload Form Sample</shortname>  <description>Form for uploading file content and meta-data into Repository</description>  <url>/simpleui/document/upload</url>  <authentication>user</authentication></webscript>‍‍‍‍‍‍‍

and my  upload.post.js   is

var filename = null;var content = null;var title = "";var description = "";// locate file attributesfor 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 locatedif (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.encoding = "UTF-8";  upload.properties.title = title;  upload.properties.description = description;  upload.save();   // setup model for response template  model.upload = upload;}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

and my upload.post.html.ftl is
<META      HTTP-EQUIV="Refresh"     CONTENT="1; URL=${url.serviceContext}/simpleui/document/list.html"><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><td>Alfresco ${server.edition} v${server.version}     <tr><td><td>      <tr><td><td>Uploaded <a href="${url.serviceContext}/sample/folder${upload.displayPath}">${upload.name}</a> of size ${upload.properties.content.size}.     <tr>       <td><a href="${url.serviceContext}/simpleui/document/list.html">Back to list page</a>     </tr>   </table> </body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

the complete DocumentList.get.html.ftl is  (this is a home page,,, here only i'm having various links for creating folder,uploading document, creating a text file etc)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head>   <title>Alfresco Simple UI</title>   <script type="text/javascript">      var djConfig = {         isDebug: true         ,debugAtAllCosts: true      };   </script>   <script type="text/javascript" src="${url.context}/scripts/ajax/dojo/dojo.js"></script>   <script type="text/javascript">      dojo.require("dojo.widget.FilteringTable");      dojo.require("dojo.widget.InlineEditBox");      dojo.require("dojo.widget.Dialog");      dojo.require("dojo.event.*");      dojo.hostenv.writeIncludes();            var dlg,previewdlg,removedlg,sdlg,udlg;      function init(e) {         dlg        = dojo.widget.byId("DialogContent");         previewdlg = dojo.widget.byId("DialogPreview");         removedlg  = dojo.widget.byId("DialogRemove");         sdlg        = dojo.widget.byId("SpaceDialog");         udlg        = dojo.widget.byId("UploadDialog");      }      dojo.addOnLoad(init);            function populate(id,noderef) {         document.getElementById("file_label").innerHTML='Edit File';         document.forms['edit_new_form'].action = '${url.serviceContext}/simpleui/document/save';         document.getElementById("file_name").value=document.getElementById("name_"+id).innerHTML;         document.getElementById("file_description").value=document.getElementById("desc_"+id).innerHTML;         document.getElementById("file_body").value=document.getElementById("body_"+id).innerHTML;         document.getElementById("file_noderef").value=noderef;         dlg.show();      }      function populatepreview(id) {         document.getElementById("preview_name").innerHTML=document.getElementById("name_"+id).innerHTML;         document.getElementById("preview_body").innerHTML=document.getElementById("body_"+id).innerHTML;         previewdlg.show();      }            function populateremove(id,noderef) {         document.getElementById("remove_name").value=document.getElementById("name_"+id).innerHTML;         document.getElementById("remove_noderef").value=noderef;         removedlg.show();      }      function create() {         document.getElementById("file_label").innerHTML='Create File';         document.forms['edit_new_form'].action = '${url.serviceContext}/simpleui/document/create';         dlg.show();      }      function createSpace() {         document.getElementById("space_label").innerHTML='Create Space';         document.forms['space_new'].action = '${url.serviceContext}/simpleui/document/createSpace';         sdlg.show();      }      function uploadFile() {         document.getElementById("upload_label").innerHTML='Upload a File';         document.forms['upload_new'].action = '$action="${url.serviceContext}/simpleui/document/upload';         udlg.show();      }   </script>   <style type="text/css">      /***         The following is just an example of how to use the table.         You can override any class names to be used if you wish.      ***/      table {         font-family:Lucida Grande, Verdana;         font-size:0.8em;         width:100%;         border:1px solid #ccc;         border-collapse:collapse;         cursor:default;      }      table td,      table th{         padding:2px;         font-weight:normal;      }      table thead td, table thead th {         background-image:url(${url.context}/images/dojo/ft-head.gif);         background-repeat:no-repeat;         background-position:top right;      }      table thead td.selectedUp, table thead th.selectedUp {         background-image:url(${url.context}/images/dojo/ft-headup.gif);      }      table thead td.selectedDown, table thead th.selectedDown {         background-image:url(${url.context}/images/dojo/ft-headdown.gif);      }               table tbody tr td{         border-bottom:1px solid #ddd;      }      table tbody tr.alt td{         background: #e3edfa;      }      table tbody tr.selected td{         background: yellow;      }      table tbody tr:hover td{         background: #a6c2e7;      }      table tbody tr.selected:hover td{         background:#ff9;      }      #inputArea{         margin:1em 0;         padding:1em;         background-color:#eef;      }      #updateTestInput{         border:1px solid #ccc;         width:100%;         height:80px;         font-family:serif;         font-size:0.9em;         overflow:auto;      }            .bar a img {         border:0;         vertical-align: middle;      }            .dojoDialog {         background : #eee;         border : 1px solid #999;         -moz-border-radius : 5px;         padding : 4px;         width: 80%      }            .footer {         text-align: center;         position:absolute;          font-family:Lucida Grande, Verdana;         font-size:0.8em;         bottom:10px;         left: 35%      }   </style></head><body>   <div dojoType="dialog" id="DialogPreview" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">      <table>         <tbody>            <tr>               <th><b>Previw File </b><div id="preview_name"></div></th>            </tr>            <tr>               <td><div id="preview_body"></div></td>                           </tr>            <tr>               <td align="center"><input type="button" id="hide3" value="Close" onClick="previewdlg.hide()"></td></td>                           </tr>         </tbody>      </table>      </div>   <div dojoType="dialog" id="DialogRemove" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">   <form name="remove_form" action="${url.serviceContext}/simpleui/document/remove" method="post">         <table>         <tbody>            <tr>               <th><b>Remove File </b><INPUT type="text" id="remove_name" name="name" value="" disabled/></th>            </tr>            <tr>               <td>Do you really really really want to delete this file?</td>                           </tr>            <tr>               <td align="center">               <INPUT type="hidden" id="remove_noderef" name="noderef" value=""/>               <INPUT type="hidden" id="remove_name" name="name" value=""/>               <input type="submit" value="Ok"/>               <input type="button" id="hide3" value="Cancel" onClick="removedlg.hide()"></td></td>                           </tr>         </tbody>      </table>   </form>      </div>   <div dojoType="dialog" id="DialogContent" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">   <form name="edit_new_form" action="" method="post">      <table>         <tbody>            <tr>               <th colspan="2"><b><div id="file_label"></div></b></th>            </tr>            <tr>               <td>Name</td>               <td><input id="file_name" name="name" type="text"></td>            </tr>            <tr>               <td>Description</td>               <td><input id="file_description" name="desc" type="text" size="60"></td>            </tr>            <tr>               <td valign="top">Body</td>               <td><textarea id="file_body" name="body" rows="10" cols="60"></textarea></td>            </tr>            <tr>               <td colspan="2" align="center">                  <INPUT type="hidden" id="file_noderef" name="noderef" value=""/>                  <INPUT type="submit" value="Save">                  <input type="button" id="hider2" value="Cancel" onClick="dlg.hide()"></td>            </tr>         </tbody>      </table>   </form>   </div><div dojoType="dialog" id="SpaceDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">   <form name="space_new" action="" method="post">      <table>         <tbody>            <tr>               <th colspan="2"><b><div id="space_label"></div></b></th>            </tr>            <tr>               <td>Name</td>               <td><input id="space_name" name="sn" type="text"></td>            </tr>            <tr>               <td>Title</td>               <td><input id="space_title" name="st" type="text"></td>            </tr>            <tr>               <td>Description</td>               <td><input id="space_description" name="sd" type="text" size="60"></td>            </tr>                        <tr>               <td colspan="2" align="center">                  <INPUT type="hidden" id="file_noderef" name="noderef" value=""/>                  <INPUT type="submit" value="Create">                  <input type="button" id="hider2" value="Cancel" onClick="sdlg.hide()"></td>            </tr>         </tbody>      </table>   </form>   </div><div dojoType="dialog" id="UploadDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"><form name="upload_new" action="" method="post">   <table>   <tbody>      <tr>         <th colspan="2"><b><div id="upload_label"></div></b></th>      </tr>          <tr><td>File:<td><input type="file" name="file">          <tr><td>Title:<td><input name="title">          <tr><td>Description:<td><input name="desc">          <tr><td><td>          <tr>         <td colspan="2" align="center">                        <input type="submit" name="submit" value="Upload">            <input type="button" id="hider2" value="Cancel" onClick="udlg.hide()"></td>         </tr>   </tbody>    </table> </form></div>   <h3>Simple Alfresco User Interface</h3>   <h4>Hello ${person.properties.firstName}!</h4>   <tr>   <b>Create a File   <img src="${url.context}/images/icons/add.gif" onClick="create();"/>   Create a Space   <img src="${url.context}/images/icons/folder.gif" onClick="createSpace();"/></b>   Upload a file   <img src="${url.context}/images/icons/add.gif" onClick="uploadFile();"/></b>   </tr>   <table dojoType="filteringTable" id="documentList" alternateRows="true" maxSortable="2"         cellpadding="0" cellspacing="0" border="0">             <thead>      <tr>         <th field="Name" dataType="String" sort="asc" valign="top">Name</th>         <th field="DateAdded" dataType="DateTime" align="center" valign="top">Created</th>         <th field="DateModified" dataType="DateTime" align="center" valign="top">Modified</th>         <th dataType="html">Description</th>         <!–         <th dataType="html">Body</th>         â€“>         <th dataType="html">Actions</th>      </tr>   </thead>   <tbody>     <#list resultset as node>     <tr value="${node_index + 1}">       <td><div id="name_${node_index + 1}">${node.name}</div></td>       <td>${node.properties.created?datetime}</td>       <td>${node.properties.modified?datetime}</td>       <td><div id="desc_${node_index + 1}">${node.properties.description}</div></td>     <!–       <td><div id="body_${node_index + 1}">${node.content}</div></td>     –>         <td>          <div class="bar">             <a href="#" onClick="populatepreview('${node_index + 1}')"><img src="${url.context}/images/icons/preview.gif"/></a>             <a href="#" onClick="populate('${node_index + 1}','${node.nodeRef}')"><img src="${url.context}/images/icons/edit_icon.gif"/></a>             <a href="${url.serviceContext}/api/node/content/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/${node.name?url}"><img src="${url.context}/images/icons/CheckOut_icon.gif"/></a>             <a href="#" onClick="populateremove('${node_index + 1}','${node.nodeRef}')"><img src="${url.context}/images/icons/delete.gif"/></a>                 </div>       </td>     </tr>       </#list>   </tbody>   </table>   <div class="footer">            Alfresco. &copy; 2009-2010 All rights reserved.   </div></body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Please give any ideas on this….
10 REPLIES 10

openpj
Elite Collaborator
Elite Collaborator
I think it could be a problem here:
      function uploadFile() {         document.getElementById("upload_label").innerHTML='Upload a File';         document.forms['upload_new'].action = '$action="${url.serviceContext}/simpleui/document/upload';         udlg.show();      }‍‍‍‍‍‍‍

I think you can try to change the action value of the form in this way:
      function uploadFile() {         document.getElementById("upload_label").innerHTML='Upload a File';         document.forms['upload_new'].action = '${url.serviceContext}/simpleui/document/upload';         udlg.show();      }‍‍‍‍‍‍‍
Hope this helps.

mialfresco
Champ in-the-making
Champ in-the-making
Hi Pj,
I'm trying the way which you have been suggested but still no luck.
Now it is displaying the following error message in browser.

The Web Script /alfresco/service/simpleui/document/upload has responded with a status of 400 - Bad Request.400 Description:   Request sent by the client was syntactically incorrect. Message:   Uploaded file cannot be located in request‍‍‍‍‍‍

mikeh
Star Contributor
Star Contributor
You should take some time and learn to use the JavaScript debugger - it's an excellent help in these situations.

Try changing
field.name == "file"‍
to
field.name == "filedata"‍

Mike

mialfresco
Champ in-the-making
Champ in-the-making
Thanks Mike thanks for your help.
But now it is showing "formdata" is not found.
I know this variable was not present in 2.1 version.
But i'm using labs 3.0 stable version.

The following is error log in mozilla 3.0

500 Description:    An error inside the HTTP server which prevented it from fulfilling the request. Message:   Wrapped Exception (with status template): Failed to execute script '/alfresco/demo/test/simpleui/upload.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': ReferenceError: "formdata" is not defined. (AlfrescoScript#7)    Exception:   org.mozilla.javascript.EcmaError - ReferenceError: "formdata" is not defined. (AlfrescoScript#7)       org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)   org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)   org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3413)   org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)   org.mozilla.javascript.gen.c26._c0(AlfrescoScript:7)   org.mozilla.javascript.gen.c26.call(AlfrescoScript)   org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)   org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)   org.mozilla.javascript.gen.c26.call(AlfrescoScript)   org.mozilla.javascript.gen.c26.exec(AlfrescoScript)   org.mozilla.javascript.Context.evaluateString(Context.java:1196)   org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:390)   org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:122)   org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:263)   org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:108)   org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:800)   org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:90)   org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:319)   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:368)   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:390)   org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:273)   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:261)   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)   org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)   org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)   org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)   java.lang.Thread.run(Thread.java:595)    Exception:   org.alfresco.error.AlfrescoRuntimeException - ReferenceError: "formdata" is not defined. (AlfrescoScript#7)       org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:406)    Exception:   org.alfresco.scripts.ScriptException - Failed to execute script '/alfresco/demo/test/simpleui/upload.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': ReferenceError: "formdata" is not defined. (AlfrescoScript#7)       org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:126)    Exception:   org.alfresco.web.scripts.WebScriptException - Wrapped Exception (with status template): Failed to execute script '/alfresco/demo/test/simpleui/upload.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': ReferenceError: "formdata" is not defined. (AlfrescoScript#7)       org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:595)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

and he following is my complete upload.post.js    file.

    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 == "filedata" && 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.encoding = "UTF-8";      upload.properties.title = title;      upload.properties.description = description;      upload.save();      // setup model for response template      model.upload = upload;    }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

mialfresco
Champ in-the-making
Champ in-the-making
Hi team,
Any idea on this?

jpfi
Champ in-the-making
Champ in-the-making
Hi,
try to set enctype="multipart/form-data" in your html-form declaration.
Cheers, Jan

mialfresco
Champ in-the-making
Champ in-the-making
Hi Jan,
I'm trying the way which u have been suggested but still no luck.
It is displaying the following error message in browser.
The Web Script /alfresco/service/simpleui/document/upload has responded with a status of 400 - Bad Request.400 Description:   Request sent by the client was syntactically incorrect. Message:   Uploaded file cannot be located in requestServer:   Alfresco Labs v3.0.0 (Stable 1526) schema 1,002Time:   Jul 2, 2009 12:19:51 PM    Diagnostics:   Inspect Web Script (alfresco/demo/test/simpleui/upload.post)‍‍‍‍‍‍‍‍‍

My upload form is DocumentList.get.html.ftl (This is a some part of the entire form)
<div dojoType="dialog" id="UploadDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"><form name="upload_new" action="" enctype="multipart/form-data" method="post" >   <table>   <tbody>      <tr>         <th colspan="2"><b><div id="upload_label"></div></b></th>      </tr>          <tr><td>File:<td><input type="file" name="file">          <tr><td>Title:<td><input name="title">          <tr><td>Description:<td><input name="desc">          <tr><td><td>          <tr>         <td colspan="2" align="center">                        <input type="submit" name="submit" value="Upload">            <input type="button" id="hider2" value="Cancel" onClick="udlg.hide()"></td>         </tr>   </tbody>    </table> </form></div>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The entire DocumentList.get.html.ftl is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head>   <title>Alfresco Simple UI</title>   <script type="text/javascript">      var djConfig = {         isDebug: true         ,debugAtAllCosts: true      };   </script>   <script type="text/javascript" src="${url.context}/scripts/ajax/dojo/dojo.js"></script>   <script type="text/javascript">      dojo.require("dojo.widget.FilteringTable");      dojo.require("dojo.widget.InlineEditBox");      dojo.require("dojo.widget.Dialog");      dojo.require("dojo.event.*");      dojo.hostenv.writeIncludes();            var dlg,previewdlg,removedlg,sdlg,udlg;      function init(e) {         dlg        = dojo.widget.byId("DialogContent");         previewdlg = dojo.widget.byId("DialogPreview");         removedlg  = dojo.widget.byId("DialogRemove");         sdlg        = dojo.widget.byId("SpaceDialog");         udlg        = dojo.widget.byId("UploadDialog");      }      dojo.addOnLoad(init);            function populate(id,noderef) {         document.getElementById("file_label").innerHTML='Edit File';         document.forms['edit_new_form'].action = '${url.serviceContext}/simpleui/document/save';         document.getElementById("file_name").value=document.getElementById("name_"+id).innerHTML;         document.getElementById("file_description").value=document.getElementById("desc_"+id).innerHTML;         document.getElementById("file_body").value=document.getElementById("body_"+id).innerHTML;         document.getElementById("file_noderef").value=noderef;         dlg.show();      }      function populatepreview(id) {         document.getElementById("preview_name").innerHTML=document.getElementById("name_"+id).innerHTML;         document.getElementById("preview_body").innerHTML=document.getElementById("body_"+id).innerHTML;         previewdlg.show();      }            function populateremove(id,noderef) {         document.getElementById("remove_name").value=document.getElementById("name_"+id).innerHTML;         document.getElementById("remove_noderef").value=noderef;         removedlg.show();      }      function create() {         document.getElementById("file_label").innerHTML='Create File';         document.forms['edit_new_form'].action = '${url.serviceContext}/simpleui/document/create';         dlg.show();      }      function createSpace() {         document.getElementById("space_label").innerHTML='Create Space';         document.forms['space_new'].action = '${url.serviceContext}/simpleui/document/createSpace';         sdlg.show();      }               function uploadFile() {         document.getElementById("upload_label").innerHTML='Upload a File';         document.forms['upload_new'].action = '${url.serviceContext}/simpleui/document/upload';         udlg.show();      }/***      function uploadFile() {          document.getElementById("upload_label").innerHTML='Upload a File';               document.forms['upload_new'].action = '$action="${url.serviceContext}/simpleui/document/upload';               udlg.show();           }***/   </script>   <style type="text/css">      /***         The following is just an example of how to use the table.         You can override any class names to be used if you wish.      ***/      table {         font-family:Lucida Grande, Verdana;         font-size:0.8em;         width:100%;         border:1px solid #ccc;         border-collapse:collapse;         cursor:default;      }      table td,      table th{         padding:2px;         font-weight:normal;      }      table thead td, table thead th {         background-image:url(${url.context}/images/dojo/ft-head.gif);         background-repeat:no-repeat;         background-position:top right;      }      table thead td.selectedUp, table thead th.selectedUp {         background-image:url(${url.context}/images/dojo/ft-headup.gif);      }      table thead td.selectedDown, table thead th.selectedDown {         background-image:url(${url.context}/images/dojo/ft-headdown.gif);      }               table tbody tr td{         border-bottom:1px solid #ddd;      }      table tbody tr.alt td{         background: #e3edfa;      }      table tbody tr.selected td{         background: yellow;      }      table tbody tr:hover td{         background: #a6c2e7;      }      table tbody tr.selected:hover td{         background:#ff9;      }      #inputArea{         margin:1em 0;         padding:1em;         background-color:#eef;      }      #updateTestInput{         border:1px solid #ccc;         width:100%;         height:80px;         font-family:serif;         font-size:0.9em;         overflow:auto;      }            .bar a img {         border:0;         vertical-align: middle;      }            .dojoDialog {         background : #eee;         border : 1px solid #999;         -moz-border-radius : 5px;         padding : 4px;         width: 80%      }            .footer {         text-align: center;         position:absolute;          font-family:Lucida Grande, Verdana;         font-size:0.8em;         bottom:10px;         left: 35%      }   </style></head><body>   <div dojoType="dialog" id="DialogPreview" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">      <table>         <tbody>            <tr>               <th><b>Previw File </b><div id="preview_name"></div></th>            </tr>            <tr>               <td><div id="preview_body"></div></td>                           </tr>            <tr>               <td align="center"><input type="button" id="hide3" value="Close" onClick="previewdlg.hide()"></td></td>                           </tr>         </tbody>      </table>      </div>   <div dojoType="dialog" id="DialogRemove" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">   <form name="remove_form" action="${url.serviceContext}/simpleui/document/remove" method="post">         <table>         <tbody>            <tr>               <th><b>Remove File </b><INPUT type="text" id="remove_name" name="name" value="" disabled/></th>            </tr>            <tr>               <td>Do you really really really want to delete this file?</td>                           </tr>            <tr>               <td align="center">               <INPUT type="hidden" id="remove_noderef" name="noderef" value=""/>               <INPUT type="hidden" id="remove_name" name="name" value=""/>               <input type="submit" value="Ok"/>               <input type="button" id="hide3" value="Cancel" onClick="removedlg.hide()"></td></td>                           </tr>         </tbody>      </table>   </form>      </div>   <div dojoType="dialog" id="DialogContent" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">   <form name="edit_new_form" action="" method="post">      <table>         <tbody>            <tr>               <th colspan="2"><b><div id="file_label"></div></b></th>            </tr>            <tr>               <td>Name</td>               <td><input id="file_name" name="name" type="text"></td>            </tr>            <tr>               <td>Description</td>               <td><input id="file_description" name="desc" type="text" size="60"></td>            </tr>            <tr>               <td valign="top">Body</td>               <td><textarea id="file_body" name="body" rows="10" cols="60"></textarea></td>            </tr>            <tr>               <td colspan="2" align="center">                  <INPUT type="hidden" id="file_noderef" name="noderef" value=""/>                  <INPUT type="submit" value="Save">                  <input type="button" id="hider2" value="Cancel" onClick="dlg.hide()"></td>            </tr>         </tbody>      </table>   </form>   </div><div dojoType="dialog" id="SpaceDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true">   <form name="space_new" action="" method="post">      <table>         <tbody>            <tr>               <th colspan="2"><b><div id="space_label"></div></b></th>            </tr>            <tr>               <td>Name</td>               <td><input id="space_name" name="sn" type="text"></td>            </tr>            <tr>               <td>Title</td>               <td><input id="space_title" name="st" type="text"></td>            </tr>            <tr>               <td>Description</td>               <td><input id="space_description" name="sd" type="text" size="60"></td>            </tr>                        <tr>               <td colspan="2" align="center">                  <INPUT type="hidden" id="file_noderef" name="noderef" value=""/>                  <INPUT type="submit" value="Create">                  <input type="button" id="hider2" value="Cancel" onClick="sdlg.hide()"></td>            </tr>         </tbody>      </table>   </form>   </div><div dojoType="dialog" id="UploadDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"><form name="upload_new" action="" enctype="multipart/form-data" method="post" >   <table>   <tbody>      <tr>         <th colspan="2"><b><div id="upload_label"></div></b></th>      </tr>          <tr><td>File:<td><input type="file" name="file">          <tr><td>Title:<td><input name="title">          <tr><td>Description:<td><input name="desc">          <tr><td><td>          <tr>         <td colspan="2" align="center">                        <input type="submit" name="submit" value="Upload">            <input type="button" id="hider2" value="Cancel" onClick="udlg.hide()"></td>         </tr>   </tbody>    </table> </form></div>   <h3>Simple Alfresco User Interface</h3>   <h4>Hello ${person.properties.firstName}!</h4>   <tr>   <b>Create a File   <img src="${url.context}/images/icons/add.gif" onClick="create();"/>   Create a Space   <img src="${url.context}/images/icons/folder.gif" onClick="createSpace();"/>   Upload a file   <img src="${url.context}/images/icons/add.gif" onClick="uploadFile();"/></b>   </tr>   <table dojoType="filteringTable" id="documentList" alternateRows="true" maxSortable="2"         cellpadding="0" cellspacing="0" border="0">             <thead>      <tr>         <th field="Name" dataType="String" sort="asc" valign="top">Name</th>         <th field="DateAdded" dataType="DateTime" align="center" valign="top">Created</th>         <th field="DateModified" dataType="DateTime" align="center" valign="top">Modified</th>         <th dataType="html">Description</th>                  <th dataType="html">Body</th>                  <th dataType="html">Actions</th>      </tr>   </thead>   <tbody>     <#list resultset as node>     <tr value="${node_index + 1}">       <td><div id="name_${node_index + 1}">${node.name}</div></td>       <td>${node.properties.created?datetime}</td>       <td>${node.properties.modified?datetime}</td>       <td><div id="desc_${node_index + 1}">${node.properties.description}</div></td>          <td><div id="body_${node_index + 1}">${node.content}</div></td>          <td>          <div class="bar">             <a href="#" onClick="populatepreview('${node_index + 1}')"><img src="${url.context}/images/icons/preview.gif"/></a>             <a href="#" onClick="populate('${node_index + 1}','${node.nodeRef}')"><img src="${url.context}/images/icons/edit_icon.gif"/></a>             <a href="${url.serviceContext}/api/node/content/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/${node.name?url}"><img src="${url.context}/images/icons/CheckOut_icon.gif"/></a>             <a href="#" onClick="populateremove('${node_index + 1}','${node.nodeRef}')"><img src="${url.context}/images/icons/delete.gif"/></a>                 </div>       </td>     </tr>       </#list>   </tbody>   </table>   <div class="footer">            Alfresco. &copy; 2009-2010 All rights reserved.   </div></body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

my upload.post.js is

    var content = null;
    var title = "";
    var description = "";

    // locate file attributes
    ...

















































































Thanks for your support.

jpfi
Champ in-the-making
Champ in-the-making
Hi,
I'm not familar with dojo, but I don't see any clientside code where you define the file hat should be uploaded…
Cheers, Jan

mialfresco
Champ in-the-making
Champ in-the-making
Hi jp,
I don't know why it is not working earlier.
Now i just replaced the new java script (similar to old one)… then it is working like a champ.
The following is my new .js file.
var filename = null;var content = null;var title = "";var description = "";// locate file attributesfor 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 locatedif (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.encoding = "UTF-8";  upload.properties.title = title;  upload.properties.description = description;  upload.save();   // setup model for response template  model.upload = upload;}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

In this one i have some couple of concerns.

1.This is uploding the files under comanyhome(root home) because of
upload = companyhome.createFile("upload" + companyhome.children.length + "_" + filename) ;‍
i think. The if i want to upload the file into a specific folder let us say  comanyhome\personal\documents how to change this location is .js file ?
2.The second one is, when i uploading a file in this way it is appended "upload10_" for every file. for ex: upload10_sample.txt (The actual file name is sample.txt).. how to change this?
if i upload another file it is uploaded like upload11_xxx.txt..etc actual name is xxx.txt