I am hosting a HTML file in Sybase 10 and it works so far good. I want now to add img Tag in my HTML but it doesnt work, because img Tag expects a relative path to the img as "src". Now the question is, what is the current folder for my webservice? I tried the path of dbsrv10.exe but without success "C:\Program Files (x86)\SQL Anywhere 10\win32" The script in DB looks something like: create PROCEDURE hello_world( ) RESULT (html_doc long varchar) BEGIN CALL dbo.sa_set_http_header( 'Content-Type', 'text/html' ); select '<!DOCTYPE html>\n' || '<html lang="en">\n' || '<body>\n' || 'hello world || '<imgg srcc="010.jpg">\n' || '</body>\n' || '</html>\n'; END; create SERVICE hello_world TYPE 'RAW' AUTHORIZATION OFF USER DBA AS CALL hello_world; |
Hi Sarkis, maybe this sample helps: https://www.db-tecknowledgy.info/fileshare/public/SQLAnyIcon.SQL HTH Thank you all. I found a good solution using IIS, so I added a virtual directory in IIS and then used the full URL in my HTML to access each photo from this virtual directory. Something like: <imgg srcc="http://my_ip/my_directory/111.jpg"> I write imgg instead of img and srcc instead of src in order to avoid HTML interpreting on this page.
(27 Jun '19, 09:00)
Baron
|
One possible solution was for example to share the folder containing the image and then use "file://computername/folder/010.jpg".
So something like: "<<imgg srcc="file://computername/temp/010.jpg">>"
you should create a service that will return the images from DB using the provided URL. On high-level, just create an HTTP procedure that listens: /prefix/***
http://sqlanywhere.blogspot.com/2015/01/calling-stored-procedures-from-html.html
and when you see a request that has: /prefix/image.jpg, you can read the JPG file from your table and return as a binary data.
URLs starting from file:// -- are local URLs. The browser will try to find the image from the user's computer.
Do you mean that I should read the images from its path and save it in DB? And then the Webservice takes the image from DB and returns it as a response? This causes me a big problem with DB-Size!!
Anyway, could you please tell me how can I read a jpg file and save it in DB-Table as binary?
Well, the web service could also return an image file from a directory which is accessable from the database server. You can use xp_read_file() to read the file contents as blob - if you store it within a SQL variable (or a table column), be sure to use a varbinary type.
Whether you choose to store images in the database or in a file directory is up to you.
FWIW, the SQL Anywhere samples include several web service samples, among others - I guess also for v10:
Thanks for the answer, is great to have a way to read the jpg files from disk and include it then in my HTTP response. In this way I can avoid using IIS which is very system independent.
Only I couldnt open the links/attachments in your last comment (I see only plain text with gray background)
It is no link, just a snippet from the reame.txt file of the SQL Anywhere 12\Samples\SQLAnywhere\HTTP\ samples directory. I think your install should include the same files (probably in a different version).