Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Location
    Atlanta, GA
    Posts
    171
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Path name on a MAC?

    I wrote the following to make sure that the images that my script will be uploading do not have embedded blanks. It works fine, but not on a MAC. I did not discover this because I do not have a MAC. but the person that I wrote this for does, and she cant use it because of this problem. I suspect it has something to do with me splitting the path up with the backslashes. Is it possible to make this work with a MAC?

    Thanks,
    -tdavis

    var elmArray = document.upload.elements;
    for (var i=elmArray.length-1;i>-1;i--){
    if (elmArray[i].type == "file" && elmArray[i].value != "") {
    var text = elmArray[i].value;
    var spit = text.split("\\");
    //alert(text);
    for (x in spit)
    {
    count++;
    }
    text = spit[x];
    for(c=0;c<text.length;c++) {
    if(text.charAt(c)==' ') {
    blerrors++;
    elmArray[i].className = "inputreq";
    }}}}

  • #2
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Microsoft operating systems use back-slashes in paths. Other operating systems, including UNIX and Linux variants (e.g. MacOSX, RedHat, Suse), use forward-slashes.

    Try this.
    Code:
    var spit = text.split(/[\/\\]/);
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Location
    Atlanta, GA
    Posts
    171
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Thanks!

    I am told that this worked (I dont have the MAC)...
    Thank you very much!

  • #4
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're welcome

    It's so much easier to do web programming when you know how to use RegExp and some have background knowledge of how file systems and the WWW work.
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •