Uploading via flash. Works for PC but not Mac. Why?

Discussion in 'Web Design and Development' started by iHateMacs, Aug 13, 2008.

  1. iHateMacs macrumors 6502a

    iHateMacs

    Joined:
    Aug 13, 2008
    Location:
    Coventry, UK
    #1
    Hi. I don't even own a Mac, but I have a Mac related problem.

    On my website http://www.wallfillers.com/photo2canvas.htm I have a small flash movie that allows people to upload images to our server.

    It works fine mostly, but I have noticed that the few people that DO have problems are all Mac users.

    After choosing the file to upload, you normally see a progress bar as the file is being sent to the server. Mac users do not see this. They can choose the file ok, but then it just goes no further.

    It works fine for Windows users. It wasn't much of a problem when the general public used it,(one or two people emailing a photo didn't matter) but we are doing a marketing push toward the professional photographer and the majority of those people use Macs.

    I am using FileReference.upload within the actionscript to do the actual upload.

    Any ideas why this should not work for a Mac when it works fine for Windows?

    Thanks

    Paul
     
  2. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #2
    Since you didn't post any code here, I suggest you take a moment and visit this page to see a valid, working example of how to do uploads via Flash and actionscripting this is platform independent. Compare your method with this proven method and go from there.

    I cannot account for why Mac's alone don't work, but have you confirmed Linux also fails, and that its not browser related (i.e. Safari, FFox)? Your server only knows it's a Mac based on the user agent, so is your code checking that?

    -jim
     
  3. iHateMacs thread starter macrumors 6502a

    iHateMacs

    Joined:
    Aug 13, 2008
    Location:
    Coventry, UK
    #3
    Thanks for your help. I will check that link.

    Unfortunately the people who are experiencing the problems are not particularly computer savvy so trying to get any specifics from them is not easy.

    I do not know about Linux. I have a mothballed Linux box at home. I might try firing that up and seeing what happens.

    The code I use is based on this http://blog.joshbuhler.com/index.ph...&day=12&name=uploading-files-in-flash-8&page=

    It looks basically the same as the code in your link.

    I have added the script from the link you gave me to my site. Could you try to upload something and see what it says please? http://www.wallfillers.com/fileref/

    I did read yesterday that there was some "problem" with OS before OS X 10.3, but that was only regarding seeing the progress of an upload.

    As a Windows person I have no idea of the chronology of Mac OS. Is X 10.3 old now? Will most people use that or better?
     
  4. iHateMacs thread starter macrumors 6502a

    iHateMacs

    Joined:
    Aug 13, 2008
    Location:
    Coventry, UK
    #4
    Thanks again for that link. I emailed the link to the person who had problems before and he was able to upload ok.

    I will have to follow through the "new" code inch by inch to see how it differers from mine.
     
  5. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #5
    Not near a Mac at present.

    10.3 is relatively old, i.e. 10.4 series is Tiger which has been around for years and is quite stable and now they're up to 10.5 which is Leopard, released this year. But since the user was able to upload using the new code from the link, it's a simple matter of debugging on your part. Sometimes when people blog and post code it's not cross platform compatible or doesn't follow standards in part or at all, so on such occasions you simply find better code and try again when weird stuff like this happens. But let's be honest, even Microsoft doesn't support W98 anymore so if someone is running a machine from another era, don't break your back too much. It's often more cost effective for them to upgrade than to pay a developer oodles of cash adjusting code to retroactively support all the older platforms. Be selective about that, is my point.

    That's the price for open source development! Saves money, not always time.

    -jim
     
  6. iHateMacs thread starter macrumors 6502a

    iHateMacs

    Joined:
    Aug 13, 2008
    Location:
    Coventry, UK
    #6
    Thanks Jim for that

    Problem is now solved.

    I had to buy a Powerbook G4 from ebay just to allow me to find this problem. I must say it was worth it. I should really change my name now. I find the Mac a wonderful machine. I don't think I could live with one 24/7 but I can now see why people feel love towards them and I've had it less than 24 hours. I updated it last night to 10.4.11 from 10.4.6. I don't know if it's worth putting Leopard on it for what I need it for.

    Anyway the problem....

    It boils down to the way the Mac and the PC handle spaces in query strings. Maybe it's just the flash player on the Mac that is the problem rather than the Mac itself. Maybe it's just Safari, I hadn't tried Firefox.

    When uploading via flash, when it is using the PHP server side script that handle the upload, my action script passes extra info in the form of a query string. This is a unique number to identify the file later and a text description.

    It is the spaces in this text that breaks the thing. A quick replacement with %20 will do the trick.


    EDIT: Firefox is the same.
     
  7. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #8
    It's up to the developer to properly parse and process filenames such as converting spaces to underscores or stripping them entirely so they can be processed by the local file system. Flash is simply the interface between the client and the local file system and the code should process the filename accordingly:

    1) decode HTML entities (i.e. all %20 become spaces plus any other encoded entities)
    2) parse accordingly (trim white space on left right, strip unwanted chars, replace chars as desired, if step one fails in your testing manually search replace %20 with space or underscore)
    3) save locally after any other checks (file size constraints, mime-type, etc. that you enforce, i.e. only allow gif uploads)

    Let the code handle the filename processing, i.e. action scripting (AS3) or PHP/JavaScript whatever you use.

    -jim
     
  8. jbucaran macrumors newbie

    jbucaran

    Joined:
    Aug 7, 2008
    #9
    Hello,

    Why don't you try my own Uploading in Flash tutorial, it definitely works on the Mac because I use a Mac.

    I hope this helps.


    J
     

Share This Page