Post folderitems with httpsocket

I am just looking for the best way to upload images to a xojo web application. It seems that uploading and presenting images by xojo itself is very slow. So I came to the idea to use a separate web server with php to upload images and present them via URL in an image well.

For the upload process I tried to use a httpsocket and a form containing a folderitem, but object references doesen’t seem to work in a form dictionary:

Dim s as New HTTPSocket
Dim d as New Dictionary

d.Value(“file”) = myFolderItem
s.SetFormData(d)

throws a “type Mismatch” error. Is there a way to post image files to a webserver or are there other solutions for my problem?

Thanks in advance,
Juergen

[quote=192311:@Jürgen Hofinger]I am just looking for the best way to upload images to a xojo web application. It seems that uploading and presenting images by xojo itself is very slow. So I came to the idea to use a separate web server with php to upload images and present them via URL in an image well.

For the upload process I tried to use a httpsocket and a form containing a folderitem, but object references doesen’t seem to work in a form dictionary:

Dim s as New HTTPSocket
Dim d as New Dictionary

d.Value(“file”) = myFolderItem
s.SetFormData(d)

throws a “type Mismatch” error. Is there a way to post image files to a webserver or are there other solutions for my problem?

Thanks in advance,
Juergen[/quote]

You cannot use the folderitem as is. d.Value must be a string. It would work with myfolderItem.Name or myFolderItem.URLPath or other path, whatever your Php requires.

@Michel Bujardet: Thanks but it’s just that I need to transfer the whole image from the client to the server somehow, not just a reference. I thought there must be a way to pack the binary of the image into the string an a way my php script can read…

You could indeed send pictures as string using a similar method as what is described here http://forums.realsoftware.com/viewtopic.php?f=2&t=43421 to code a picture as Base64. Then in the Php you would just need to decode it and save it.

I am trying to see what you want to achieve exactly, though. If your plan is to transmit all images upon launch of your app to a php for it to save them onto some web space to then use them in ImageView as URL, it will probably be even slower than simply dragging them in the project. Not to mention way more complex.

The best way to use images by their URL is to simply upload them once and for all in a web accessible space, and reference that URL in the ImageView. You can even preload them to speed up display.

Is there any reason why you want to use a Php script instead of simply uploading your images with Ftp ?

@Michel Bujardet : Thank you, i will try this …

@Michel Bujardet : The images are part of a user database. To be more precise, it’s a database to store incoming and outgoing goods. For each product we take one ore more pictures and I want to store all the data in a database which can be accessed by all people in our group. Building up the web app with xojo has been quite straight forward. Just storing the images turned out to be a little tricky (or lame).

The images could also be stored in the database itself. Since in commercial solutions this seems not the way how things are done I wanted to store the images in a server directory and reference them in the database. Currently I do this by using the WebFileUploader, but this seems to be a very slow solution compared to uploading files through a web form and php on the server side.

[quote=192355:@Jürgen Hofinger]@Michel Bujardet : The images are part of a user database. To be more precise, it’s a database to store incoming and outgoing goods. For each product we take one ore more pictures and I want to store all the data in a database which can be accessed by all people in our group. Building up the web app with xojo has been quite straight forward. Just storing the images turned out to be a little tricky (or lame).

The images could also be stored in the database itself. Since in commercial solutions this seems not the way how things are done I wanted to store the images in a server directory and reference them in the database. Currently I do this by using the WebFileUploader, but this seems to be a very slow solution compared to uploading files through a web form and php on the server side.[/quote]

You do not necessarily need to resort to php and string conversion. You can have two Xojo Web apps talk to each other, one being a web service responding through HandleURL pretty much like a php would, but afterward they can talk to each other through HTTPSocket and transfer files directly.

@Michel Bujardet : The reason for using Apache with php was mainly the slow image processing and transfer by xojo (beside the not so elegant WebFileUploader). So it wouldn’t help to communicate with another xojo application.

Meanwhile I have come to using the WebFileUploader to upload the files (even if this is very slow) and store the file path in my database. To read the images the file paths are fetched from the database, converted to URLs and the images are then served by an Apache Webserver. Maybe the next xojo release can speed up things (with file drag and drop for example?).

Geoff Perlman announced at XDC that drag and drop is coming :slight_smile: