Changes
- Added the Application Demo which demonstrates a working upload script and dealing with passing PHP Session IDs to the upload script as a work-around to the Flash/Firefox cookie issue.
- Restructured the JavaScript code to comply with YUI style suggestions and to make a clean pass at www.jslint.com. This makes for better less error prone code.
- The major change here is changing all function names to camelCase.
- Moved the Cookie and Console objects inside the SWFUpload object.
- Cleaned up some additional logic
- Created a function this.DebugMessage(msg) to replace all the if (this.debug) Console.Writeln(msg);. Which does the same thing but gets ride of the all ifs and allows for easier changes to debugging in the future.
- Added a ChangeLog.txt file and removed the 100 lines of comments from the top of the swfupload.js file.
I recommend using the full blown swfupload.js for development but then using jsmin to reduce the file from 27 KB to 16 KB.
The demo swfupload.swf also has not had any of the "This script is running too long" patches applied to it. I have not, personally, had any of these errors come up but you may want to apply the patches anyways.
I've decided it's time to learn JavaScript and have started with the resource at http://javascript.crockford.com/ which are very good and reasonable. Hopefully my understanding and coding of JavaScript will improve ;)
Hi!
ReplyDeleteThanks for your great work! I really appreciate it. Your version is much better than the original one.
I've noticed a small (but relevant) shortcoming of the software though (this applies to both your and the original version): The progress bar and the actual upload are not synchronous. If you upload a small file this is not very apparent, but if your upload a larger file (e.g. 5 MB) you notice it easily.
The progress bar is at 100% after a few seconds (at most), the actual upload might take further minutes.
Looks almost like some kind of caching-problem (or whatever) to me (don't know if servers are capable of caching incoming files).
Any ideas how to fix this?
Many thanks in advance!
Egbert02
I was wondering whether you have any demos in asp.net (version 2.0 if possible) and if you do, where I could download them. Thank you very much :)
ReplyDeleteIs it possible to send the url params as POST vars?
ReplyDelete@metro. I don't maintain any Asp.Net demos. I had some several revisions ago but I can't host them. Someone offered some PHP hosting so I switched to PHP.
ReplyDeleteSWFUpload is language agnostic. The only bit that you have to worry about is the upload target. This page should accept a file upload and process it. It's not really any different than a regular ASP.Net upload page. The file will be found in Request.Files["Filedata"].
@michael: Unfortunately the Flash Player (the bit that makes this all possible) does not give us any control over what data is sent. We can't manipulate the post data. The best we can do is send url params. I recommend against using too many url params (I only send the session id). You have to carefully encode them and different servers will treat them differently.
Hi!
ReplyDeleteI found the reason for the strange behaviour described above. It has nothing to do with SWFUpload (fortunately). It's the fault of Kaspersky Anti-Virus which I'm using at the moment.
I disabled it (more or less by chance) and SWFUpload worked like expected. I enabled it again and the problem came back.
Really strange...
Egbert02
I've come across a few instances of this happening:
ReplyDelete1. If the script does a lot of process it happens after the file is uploaded. I see this when creating thumbnails of images. The SWFUpload hits 100%, stalls while the script makes the thumbnail and then fires fileComplete.
2. I am behind a proxy server. The proxy intercepts the upload (a 600MB file uploads in 2~3 seconds). SWFUpload stalls at 100%. The proxy server makes the upload to the server (which takes the normal amount of time) and then SWFUpload fires fileComplete.
I worked around this (a bit) by having the fileProgress event check to see if the file has reached 100% and then displaying a message that says "Processing file" so the user doesn't feel like the application has stalled.
I'll bet the anti-virus software is doing the same kind of thing as the proxy server. It accepts the file, checks it for viruses and then uploads it. All SWFUpload sees is that the file has been accepted. It doesn't know it has been intercepted in the middle.
Hi,
ReplyDeleteI think your version is really cool that I could make my customized UI and make it easily to control. Thanks by the way.
And also, I actually found an minor problem. That is the setting fileTypes, it works for the file mask of file dialog, but when I try to key *.* in the file dialog, and select some type of files (that I don't allow), there is no error triggered, even thougth I could check by the fileObject.name to cacnel the file queue.
I noticed that too. But when I tried to upload a file with an invalid extension it actually crashed my browser.
ReplyDeleteI'll have to add some checks in the next revision.
In Revision 6 I am switching to ActionScript 3 and FlashPlayer 9. ActionScript 3 will allow us to get data back from the file upload, fixes some issues with invalid uploads (causes lots of problems and Macs), hopefully improves the 'cookies' bug and I hope to include Adobe's Flash detection script and automatic upgrade features.
But we'll see.
That's sound very cool!!! Looking forward to version 6.
ReplyDeleteKeep up the good work!
Jake,
ReplyDeleteThanks for the great contribution. I'm noticing the script/Flash crashing my browser at times. It happens when I cancel the file dialog (FF and Safari) and sometimes when I select a file in Safari.
Any ideas?
Thanks
Thanks Jake, for your great work. I'm using R52 in my Drupal upload module. I am just wondering if SWFUpload supports simultaneous uploads without having to instantiate multiple copies of swfupload.swf.
ReplyDeleteThanks again.
@i go by ed
ReplyDeleteI've had crashes like that in FF on Linux. I suspect bugs in the Flash Player, which means, there probably isn't anything I can do. Also, this is a hobbyist side project and even though I'd like it to work perfect for everyone I don't have the resources to worry about it. So the source is provided and if you solve the problem it'd be nice to hear how!
@nathan tran
I wondered the same thing. I had thought about trying multiple simultaneous uploads but never really got time. Maybe I'll give it a go in Revision 6 (which is coming along nicely but slowly). I don't see why it couldn't work unless Flash just doesn't support it.
Jake, first off thanks! Nice mod of an already nice util. Before I saw that you are already at work on v6, I set about converting you r5 to AS3 because I really wanted to have access to the Server Side Code's response. I have it almost all working but got hung up on one point. Thought we might share notes and maybe I could even give you a hand.
ReplyDeleteI decided that that was important enough, as well, to move to AS3.
ReplyDeleteI've got r6 mostly done. I attempted to repair the Firefox/Flash Cookie issue but even AS3 won't let you send cookies with a file upload. Silly me, not thinking I ripped out all the cookie passing features I had in r52. I need to add those features back in and it'll be about ready.
I was able to add the ability to send additional post values in AS3 as well. I'll probably build an option to submit a form along with the upload.
I've had some time constraints (and a vacation) over the last few weeks and haven't quite finished up r6.
Shoot me an email at (o t i j i m _a_t_ y a h o o _d_o_t_ c o m) and I'll see if I can give any pointers. I'm just scraping along with the Adobe LiveDocs and Google so...ymmv ;)
Hey, i often notice that on Mac/Linux the first file is not recognized and not uploaded.
ReplyDeleteFor example, if i open the page the first time and select a file to upload, it doesn't select it (it dosnt even call the upload-script) but on windows everything seems to be correct. Do you know such an error?