Upload File via Web Service

Hi All,

The question is simple: How do I do file upload via web service? There’s nothing in the documentation, and searching in google gives no result also.

Here’s the case:

I have an application that needs to save some form with file. We can upload the file in two ways: from the web app itself, and from a web service. The upload module in the web app has finished, and now I have a UploadForm that extends from the basic model. The UploadForm Class saves the file from CUploaded file, and if possible, I want to use the same form from the web service.

Unfortunately, most reference that I found via google suggest that we use base64_encode to transfer the file to the web service. Is there any way to send the file via POST just like Http Form so I can just simply use the UploadForm class?

Thanks before.

You can use SOAP stack to make life easier for you. However, there will be hardly an alternative to encoding your files via base64. So you’ll need to take care of that in your controller.

I’ve actually use the SOAP stack, but I’m looking for a way to serialize the data send via the service with the UploadForm that’s already present. The reason I would like to do this is to not write the same code twice. The UploadForm does many things, so duplicating all the codes is not a good idea, IMO.

Or is there another way to link the UploadForm’s file (CUploadedFile I think) with the base64_encoded file that the web service recieve?

Please tell me if you need more information or some code sample.

Thanks before.