Upload File To Website

I have been able to download a file from a web site using this code:

Dim DataSocket As new HTTPSocket
FPath = “http://www.xxx.com/file/df.aspx/publish/username/foldername/” + filename

name = NthField(FPath, “/”, CountFields(FPath, “/”))

DownloadDone = DataSocket.Get(FPath, f,10)

Does anyone know how to use the HTTPSockent to upload a file?

A common approach that can work fairly easily is to have a PHP script that you invoke via HTTP. Your HTTP POST contains the file data in the body of the POST. Lots of security issues to consider, of coure.

Brad, thanks for the info. I am not familiar with PHP script - could you give more detail on how to do this?

PHP is a common server-side scripting language, used for making dynamic web pages.


If you’re new to PHP, this upload thing probably isn’t a beginner project.

You can also use a Xojo web app to accept the uploaded file (instead of php).

I very much appreciate all of your suggestions. However, I feel there is something lacking in XOJO if it is so difficult to simply write a file to a web server. Why is there not a counterpart to the HTTPSocket Get (for reading a file) that would write a file? for example, in Visual Basic there is an UploadFile method (contained in MyComputer.Network) which it makes it very simple to write a file to the web.

Again, thanks for your suggestions.


You need support on that server. That means a server protocol or script running under HTTP that knows how to accept the uploaded file and deal with it. On 90+% of the servers in service on the web, that doesn’t happen out of the box. The VB method is likely depending on some feature in IIS, this tying you to a Windows server. Your question was much more general.

Hi Brad:

I am sure all the info you have relayed to me is correct but let me clarify what I am doing . I am using a cloud service called DriveHQ. This service allows the user to create directories, publish the URL to these directories and then use the published URL’s to upload and download files to and from these directories. In the case of Visual Basic, this allowed me to provide users of my software the ability to upload and download files within these directories. For Visual Basic, this used the DriveHQ published URL and the Upload and Download file methods. This has worked famously for Visual Basic. For XOJO I am able to download a file from a DriveHQ directory using the HTTPSocket.Get but I can find no method for uploading a file. There may be some security issues with my approach but to this point, I have had no problems.

Regards, Jim

I am not familiar with the specifics of DriveHQ however HTTPSocket.Post will probably work for you.

Here is a link to the docs: Page Not Found — Xojo documentation

James, Please post a snippet of code that you use to upload a file from VB. That would help us see what’s going on.

Hi Jared:

I have tried HTTPSocket.post and either I am using it incorrectly or it does not work for this purpose.


Brad, here is a snippet of VB code used to upload and download in VB:

This is the Download code:

Public FTPDownloadPath = “http://www.drivehq.com/file/df.aspx/publish/UserName/Scores/

ServerPath = FTPDownloadPath & ScoreFile

Cursor.Current = Cursors.WaitCursor

        My.Computer.Network.DownloadFile(ServerPath, LocalFilePath, UserName, UserPassword, False, 100000, True)

    Catch Ex As Exception
        Exception = True
        Status = "Scores for this week have not yet been uploaded to the server."
    End Try

    If Exception Then
        Cursor.Current = Cursors.Default
        MessageBox.Show(Status, "Scores Unavailable", MessageBoxButtons.OK, MessageBoxIcon.Information, _
                        MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
        Exit Sub
    End If

    Cursor.Current = Cursors.Default

This is the Upload code:

Public FTPUploadPath As String = “ftp://ftp.drivehq.com/scores/

ServerPath = FTPUploadPath & ScoreFileName

        My.Computer.Network.UploadFile(FilePath, ServerPath, UserName, UserPassword, True, 1000, True)

    Catch Ex As Exception
        Exception = True
        Status = "Score upload failed - server may be unavailable."
    End Try

    If Exception Then
        MessageBox.Show(Status, "Score Upload Failed", MessageBoxButtons.OK, MessageBoxIcon.Information, _
                        MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
        Exit Sub
    End If

    MessageBox.Show("Score File for week " & ScoreWeek & " has been successfully uploaded.", _
                    "Scores Uploaded", MessageBoxButtons.OK, MessageBoxIcon.Information)

In my compilation of the program, I am the administrator and the only one that can upload files. The users can only download files.

Hope this helps, Jim

Ok, so that’s using the FTP protocol to upload. Your server has an FTP server on it that you’ve configured to accept connections. This is often done at the account level when you setup a server account.

Xojo doesn’t have an FTP class built in. There are third party implementations. Not sure if the CURL functions in MBS do an ftp upload. You could probably find a “curl” for windows and run it through a Shell. Here’s some info on curl:


And here’s where to get curl for Windows and other platforms:


Brad, I do not recall doing any special configuration on DriveHQ for FTP protocol, I think it is just part of the normal service provided. I am not familiar with CURL - sounds like a lot of trouble for a simple upload capability. I like XOJO but for me, lacking this upload capability is a major flaw and I will probably continue to use VB. Thanks for trying to help.

Regards, Jim

From the DriveHQ API page (DriveHQ Reseller Programs - APIs and SDKs model):

Unfortunately, Xojo does not have FTP support built-in, which is what DriveHQ seems to use by default.

It appears that to use DriveHQ with Xojo, you’ll need to add a 3rd party product with FTP support such as MBS (using their cURL plugin) or FTP Suite.

They didn’t publish their API for review, but if it supports the use of SMTP to submit files, then that might work with the Xojo SMTPSocket. It does seem odd they don’t offer anything using straight HTTP, though.

Windows also has a built in ftp command that you could try to run from a shell.

Thanks to all who have tried to help. I will do some further discovery and see if I can come up with a way to do the file upload. I like XOJO very much and perhaps there is a way to solve this problem. Paul’s suggestion of using the SMTPSocket may be useful.

Again thanks to all.


Fastest approach for you is going to be CURL through a Shell. Test on the command prompt first, then wade through the Shell documentation.

I need to upload a file to a WE server without using the WebfileUpload control (or PHP)
Instead I need to use either CURL (HTTP PUT) or maybe a XOJO app ( HTTPSocket) at the client

I wonder how I can accept\receive the data on the WE server (without PHP etc) …?