Web Analytics Made Easy -
StatCounter Path name on a MAC? - CodingForum

Announcement

Collapse
No announcement yet.

Path name on a MAC?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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.

    Comment


    • #3
      Thanks!

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

      Comment


      • #4
        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.

        Comment

        Working...
        X