Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]

From a Java point of view, the following actually works: http://stackoverflow.com/a/17174260/1167890https://stackoverflow.com/a/17174260/1167890

I would like not to be forced back into Java/MathLink if possible though.

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]

From a Java point of view, the following actually works: http://stackoverflow.com/a/17174260/1167890

I would like not to be forced back into Java/MathLink if possible though.

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]

From a Java point of view, the following actually works: https://stackoverflow.com/a/17174260/1167890

I would like not to be forced back into Java/MathLink if possible though.

Notice removed Reward existing answer by C. E.
Bounty Ended with Christopher Haydock's answer chosen by C. E.
Notice added Reward existing answer by C. E.
Bounty Started worth 100 reputation by C. E.
Notice removed Draw attention by Simon O'Doherty
Bounty Ended with C. E.'s answer chosen by Simon O'Doherty
added 197 characters in body
Source Link

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]

From a Java point of view, the following actually works: http://stackoverflow.com/a/17174260/1167890

I would like not to be forced back into Java/MathLink if possible though.

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]

From a Java point of view, the following actually works: http://stackoverflow.com/a/17174260/1167890

I would like not to be forced back into Java/MathLink if possible though.

Updated to show a working example.
Source Link

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

I have to submit a form like as follows:

<input type="file" name="jpgFile">

I can't seem to find any instructions on sending this in URLExecute. If I specify the file name as the parameter it fails. If I try Import[filename, "JPG"] of the image it also fails as invalid.

I thought his might work, but I get an error "Iteration limit of 4096 exceeded". This suggests it might be working as test file is 451,107 bytes.

URLExecute[ url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"jpgFile", "file"} -> "test.jpg"
  }
 ]

So this is another example. In this instance I am sending a text file and this appears to work.

testData = Import["test.txt","Text"];

URLExecute[
 url,
 "Method" -> "POST",
 "Headers" -> {
   "Accept" -> "application/json; charset=UTF-8"
   },
 "MultipartElements" -> { 
   {"textData", "text/plain"} -> testData
   }
 ]
Tweeted twitter.com/StackMma/status/656525804478844928
Notice added Draw attention by Simon O'Doherty
Bounty Started worth 100 reputation by Simon O'Doherty
fixed missing line.
Source Link
Loading
Source Link
Loading