WebFileUploader

I am getting extremely frustrated with the WebFileUploader control. I am at my wits end. I have a simple form where users fill out a few textfields, select a few items from popup buttons and select files to upload using the WebFileUploader control. When the user clicks “Submit” on the form it always sends it (via email) without fail, regardless of whether the user has selected files to upload or not. However, if the user has selected files to upload it is a 70/30 chance that it will actually upload the files. When it doesn’t upload the user gets no error and it appears as if everything works but the files never show up on the server. If the user clicks “Submit” again (the form is not cleared each time the user submits) then the files may or may not upload the second time. It’s a crap shoot.

I’ve tried running the application as a CGI and as a standalone. It’s the same either way. I’ve tried using the “file.Save” method and the "output = BinaryStream.Create(outputFile, True) method. Same results.

I’m at a loss. The customer is starting to get annoyed and is suggesting I find another dev platform which I don’t want to do.

Here is the code within the UploadComplete section where this takes place:

Dim outputFile As FolderItem
Dim output As BinaryStream
Dim r As New Random
Dim i As Integer
For Each file As WebUploadedFile In files
Try
if Lowercase(file.Name)=“image.jpg” then
i = r.InRange(0, 999999)
outputFile = New FolderItem(ReplaceAll("/JobImages/"+str(i)+""+txtJobNum.Text+""+file.Name," “,”"))
else
outputFile = New FolderItem(ReplaceAll("/JobImages/"+txtJobNum.Text+"
"+file.Name," “,”"))
end if
output = BinaryStream.Create(outputFile, True)
output.Write(file.Data)
output.Close
if Lowercase(file.Name)=“image.jpg” then
Session.FileList.Append(ReplaceAll(ImageServer + “/JobImages/” + str(i) + "
" + txtJobNum.Text+""+file.Name," “,”"))
else
Session.FileList.Append(ReplaceAll(ImageServer + “/JobImages/” + txtJobNum.Text+""+file.Name," “,”"))
end if
Catch e As IOException
msgbox e.Message+" " + str(e.ErrorNumber)
Continue
Finally
End Try
Next
SendMail

As I’ve said, there are no errors and the files disappear from the FileIploader control as they should once the upload completes but they never show up on the server. As an extreme test I build another server and put the app on it. Same results.

You’re catching IOExceptions. First thing I would do is add a catch for all exceptions and see if any other types are being raised.

How big are the files? What kind of server are you running on? Can you measure RAM usage on the server side while you upload? What devices are users using to access the site?

Also, I see what you’re doing with that r as new Random thing. You might seed it with a call to microseconds. And you might check proposed filenames in a while loop until they don’t exist rather than relying solely on Random to give you something unique.

First thing would be to log things. So you definitive know if the events fire. Some people had trouble recently with xojo cloud.
Second passing a path to New folderitem without a path type is a mistake.
Better use normal folderitem methods to build a path.

My first instinct is to check your RAM usage. If you are running as CGI and all of the selected files are larger than the amount of free memory, that would explain this behavior.

As Brad said, it’d be helpful to know more about the server this is running on.

Oh, and make sure you specify he Seed property of the Random object. Otherwise you’ll probably get the same sequence over and over.

Maybe you should not use file.data here and use the temp file from Webfile directly?