I'm trying to use SWFUpload embedded in Perl, and using a Perl upload script, obviously. The debug shows the following:
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: *.*
SWF DEBUG: Select Handler: Received the files selected from the dialog. Processing the file list...
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to ../cgi-bin/upload.cgi for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadError : IO Error : File ID: SWFUpload_0_0. IO Error: Error #2038
SWF DEBUG: Event: uploadComplete : Upload cycle complete.
Error Code: IO Error, File name: collapse.gif, Message: Error #2038
I've got a second form in the page that just submits the file directly to my upload.cgi and it works fine. My webserver access log isn't showing a call to upload.cgi. Do you know of any reason that this wouldn't work?
Why perl?
Just curious, what is the benefit of using perl of php?
Perl vs PHP?
There's any number of benefits of using Perl over PHP for a full blown web application, you can research that yourself. In my case, I'm using it b/c that's what my web app is already written in, and I don't actually have any PHP handler installed on this server (it's dedicated rather than shared hosting).
Hurray for PERL
It's been years since I've coded any Perl but it's just about the most fun language I've coded in!
PHP internals?
So, knowledgeable SWFUpload people, tell me, how does the flash (actionscript?) portion of SWFUpload track file progress? That is, how does it know what to track? Does it use an environment variable (like the one PHP uses as $_FILE['Filedata']['tmp_name']) or something? I'm still trying to figure this one out.
All the javascript based PHP+Perl upload solutions I've seen involve Perl writing a temporary file on the filesystem tagged with an id that's then shared between the uploading script and the monitoring script, but I don't see that here, and am thinking that might be the source of my error, if the movie was looking for a variable PHP sets when processing a POST that isn't being set by my Perl.
I'll accept conjecture
Client Side
SWFUpload is completely client side. It can track the file progress because it is actually doing the file upload and it knows how much of the file it has sent.
I wish browsers would come along and obsolete SWFupload by providing file size and upload progress information in the standard <input type="file" /> tag. But at the rate these things move (especially changes in forms) I don't see that happening for a long while.
Client Side
Ok, so if it's client side and the progress bar merely tracks how quickly the movie is sending the file to the server script. It then waits for some response from that script (a handful of characters?) to recognize as success.
So does the upload script actually have to do anything? As an experiment, if the upload script merely sent back a success response, would SWFUpload think the file completed? If that's the case, then the #2038 I've been running into must be something unrelated. Any suggestions?
Client Side
Maybe a better question -- does anything in response from the upload script get recognized as success? I suppose any non-error code (I assume it won't take 404 as success)?
Client Side
Thanks for the help gyphie, I think I've got it sussed. I believe my server's authentication method is preventing a response from the upload script. Changing the upload script to be in the non-secure portion of the web server proved successful and seemed to bear out my conclusion.
Unfortunately it probably means SWFUpload won't be a solution for me.
Cheers!
You're right
The upload script doesn't have to do anything as long as it returns a 200 status code and (for the Flash 9 version) some content within 30 seconds of upload completion. This is what most of the demos do. They don't save the file or do much of anything except allow the web server to return a 200.
Other errors are usually caused by some server side "incompatibility". Most common are HTTP Authentication (which is not supported by the Flash Player), alternate success status (e.g., 201 or 202), redirects (302), or some kind of request validation service (Apache's mod_security).
I've also had trouble when calling Response.End() in ASP.Net.