Pass an image as a geoprocessing parameter

2108
2
Jump to solution
06-14-2016 03:38 PM
TomSellsted
MVP Regular Contributor

Greetings,

I have a JSAPI app that I have built that uses a geoprocessing tool to pass information back to our ArcGIS server.  The geoprocessing tool is used to post information to another vendors API.  I have everything working very well except for passing an image from my app. 

One of the parameters I would like to pass back is an image captured from a iPad camera.  I am using the following to capture the image:

<input id="accountPhoto" name="attachment" type="file" accept="image/*" capture="camera" data-clear-btn="true">

I have tried different variations of passing it back into the geoprocessing parameters, but I have had no luck.  What would be the proper way to pass a captured image as a geoprocessing parameter?

Regards,

Tom

0 Kudos
1 Solution

Accepted Solutions
FC_Basson
MVP Regular Contributor

Is your GP service configured to allow uploads?

If you are using API 3.x then you can upload files with a standard request:

esri.request({
  url: "http://<server>/arcgis/rest/services/GP_Services/<gservice>/GPServer/uploads/upload",
  form: dojo.byId("uploadForm"),  // dom element
  content: { f: "pjson" },
  handleAs: "json",
  load: uploadSuccess,  // callback
  error: uploadFailed   // on error
});

HTML upload form:

<form enctype="multipart/form-data" method="post" id="uploadForm">
  <div class="field">
    <label class="file-upload">
      <span><strong>Add File</strong></span>
      <input type="file" name="file" id="inFile" />
    </label>
  </div>               
</form>

View solution in original post

2 Replies
FC_Basson
MVP Regular Contributor

Is your GP service configured to allow uploads?

If you are using API 3.x then you can upload files with a standard request:

esri.request({
  url: "http://<server>/arcgis/rest/services/GP_Services/<gservice>/GPServer/uploads/upload",
  form: dojo.byId("uploadForm"),  // dom element
  content: { f: "pjson" },
  handleAs: "json",
  load: uploadSuccess,  // callback
  error: uploadFailed   // on error
});

HTML upload form:

<form enctype="multipart/form-data" method="post" id="uploadForm">
  <div class="field">
    <label class="file-upload">
      <span><strong>Add File</strong></span>
      <input type="file" name="file" id="inFile" />
    </label>
  </div>               
</form>
TomSellsted
MVP Regular Contributor

FC,

Thanks very much for your reply.  It was exactly what I was looking for.  I did not have uploads turned on either.  I got them turned on and reworked the workflow to post the uploaded photo to our vendors API.

Regards,

Tom

0 Kudos