Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

With php I can simply write a short snippet to receive an image. Like this:

$uploaddir = 'upload/';

$uploadfile = $uploaddir . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $uploadfile) )
    echo "success";
} else
    echo $uploadfile;

So my question is, does anyone know how to get this functionality with a SQLAnywhere webservice? How can I access Http variables like the $_FILES (php)?

I want to send a captured image from an android device to a SQLAnywhere webservice.

Thanks for your help! Regards

asked 08 Jun '16, 11:23

DeletedUser-1683's gravatar image

accept rate: 0%

Please see the example called "gallery.sql" that comes with the SQL Anyhere install.

The basic idea is that you can get all of the information that you need from the POST request to the server by using the HTTP_VARIABLE() function.

An excerpt from the gallery.sql example:

declare v_name  varchar(250);
declare v_type  varchar(50);
declare v_image long binary;
declare i       int;
set v_name  = http_variable( 'image', NULL, 'Content-Disposition' );
set v_type  = http_variable( 'image', NULL, 'Content-Type' );
set v_image = http_variable( 'image', NULL, '@BINARY' );
-- pick out the filename from the Content-Disposition
set i = locate( v_name, 'filename=' );
set v_name = substr( v_name, i+10 );
set i = locate( v_name, '"' );
set v_name = left( v_name, i-1 );

The v_name variable contains the file name that was uploaded and v_image contains the actual image content.

The post_data.sql and put_data.sql examples may also be of some help.


permanent link

answered 08 Jun '16, 11:37

Mark%20Culp's gravatar image

Mark Culp
accept rate: 41%

edited 08 Jun '16, 13:12

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 08 Jun '16, 11:23

question was seen: 1,770 times

last updated: 08 Jun '16, 13:12